kanzi::Node2D Class Reference

Node2D is the base class of all 2D nodes. More...

#include <kanzi/core.ui/node/node2d.hpp>

Inheritance diagram for kanzi::Node2D:
kanzi::Node kanzi::Object kanzi::MetaObject kanzi::PropertyObject kanzi::ButtonConceptImpl< Node2D, Button2D > kanzi::ButtonConceptImpl< Node2D, ToggleButton2D > kanzi::DockLayoutConceptImpl< Node2D, DockLayout2D > kanzi::FlowLayoutConceptImpl< Node2D, FlowLayout2D > kanzi::GridLayoutConceptImpl< Node2D, GridLayout2D > kanzi::EmptyNode2D kanzi::Image2D kanzi::NinePatchImage2D kanzi::Page kanzi::Portal kanzi::Screen kanzi::TrajectoryLayout2D kanzi::Viewport2D kanzi::ListBoxConceptImpl< Node2D, GridListBox2D, GridListBox2DTraits > kanzi::ListBoxItemContainerImpl< Node2D, ListBoxItemContainer2D > kanzi::PrefabViewConceptImpl< Node2D, PrefabView2D > kanzi::ScrollViewConceptImpl< Node2D, ScrollView2D > kanzi::StackLayoutConceptImpl< Node2D, StackLayout2D > kanzi::TextBlockConceptImpl< Node2D, TextBlock2D > kanzi::ToggleButtonGroupConceptImpl< Node2D, ToggleButtonGroup2D >

Classes

struct  ClippingArea
 Clipping information carried from parents. More...
 

Public Types

enum  PixelFormat { PixelFormatRgb, PixelFormatRgba }
 
enum  ForegroundHint { ForegroundHintNone, ForegroundHintTranslucent, ForegroundHintOpaque }
 Hint for foreground handling of nodes. More...
 
enum  RenderType { RenderTypeNone, RenderTypeTexture, RenderTypeManual, RenderTypeManualClipped }
 Node2D render type - affects elementary decisions about node rendering. More...
 
typedef Vector2 LayoutVectorType
 
typedef Matrix3x3 LayoutMatrixType
 
typedef vector< Node2DSharedPtrChildContainer
 Container type for children. More...
 
typedef ChildContainer::const_iterator ChildConstIterator
 Iterator type for children. More...
 
typedef ChildContainer::const_reverse_iterator ChildConstReverseIterator
 Reverse iterator type for children. More...
 
typedef NodeSharedPtr(* HitTestVisitor) (Node2D &node, Vector2 nodePoint, void *userData)
 Hit test visitor function. More...
 
- Public Types inherited from kanzi::Node
enum  HorizontalAlignment { HorizontalAlignmentLeft, HorizontalAlignmentRight, HorizontalAlignmentCenter, HorizontalAlignmentStretch }
 Horizontal alignment options. More...
 
enum  VerticalAlignment { VerticalAlignmentBottom, VerticalAlignmentTop, VerticalAlignmentCenter, VerticalAlignmentStretch }
 Vertical alignment options. More...
 
enum  DepthAlignment { DepthAlignmentBack, DepthAlignmentFront, DepthAlignmentCenter, DepthAlignmentStretch }
 Depth alignment options. More...
 
enum  ContentStretch {
  ContentStretchNone, ContentStretchFill, ContentStretchUniform, ContentStretchUniformToFill,
  ContentStretchRepeat
}
 Content stretch option. More...
 
enum  VisitorOrder { VisitorPreOrder, VisitorPostOrder }
 
enum  VisitorResult { VisitorAbort, VisitorContinue, VisitorContinueSibling }
 
typedef kanzi::vector< Node::MessageSubscriptionTokenMessageSubscriptionTokenVector
 
typedef function< VisitorResult(Node &)> Visitor
 
typedef vector< InputManipulatorSharedPtrInputManipulatorContainer
 Gets the input manipulator iterator. More...
 
typedef InputManipulatorContainer::iterator InputManipulatorIterator
 
typedef InputManipulatorContainer::const_iterator InputManipulatorConstIterator
 
typedef vector< BindingEntryBindingContainer
 Gets the bindings iterator. More...
 
typedef BindingContainer::iterator BindingIterator
 
typedef BindingContainer::const_iterator BindingConstIterator
 
typedef vector< NodeComponentEntryNodeComponentContainer
 Gets the node component iterator. More...
 
typedef NodeComponentContainer::iterator NodeComponentIterator
 
typedef NodeComponentContainer::const_iterator NodeComponentConstIterator
 
- Public Types inherited from kanzi::PropertyObject
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 

Public Member Functions

virtual ~Node2D ()
 
ChildConstIterator beginChildren () const
 
ChildConstIterator endChildren () const
 
ChildConstReverseIterator rbeginChildren () const
 
ChildConstReverseIterator rendChildren () const
 
void addChild (Node2DSharedPtr child)
 Adds a child node. More...
 
void insertChild (size_t index, Node2DSharedPtr child)
 Adds a child node for object node to given index. More...
 
void removeChild (const Node &child)
 Removes child node. More...
 
void removeChild (size_t index)
 Removes child node at specified index. More...
 
void removeAllChildren ()
 Removes all child nodes. More...
 
Node2DSharedPtr getChild (size_t index) const
 Returns a child from given index from object node. More...
 
size_t getChildIndex (const Node &child) const
 Returns the index of a child in an object node. More...
 
bool hasChild (const Node &child) const
 Returns whether or not the child exists. More...
 
size_t getChildCount () const
 Gets the number of children of the node. More...
 
void moveToBack ()
 Repositions the node to the beginning of its parent's children, so that it is drawn first. More...
 
void moveToFront ()
 Repositions the node to the end of its parent's children, so that it is drawn last. More...
 
RenderType getRenderType () const
 Get render type. More...
 
BrushSharedPtr getBackgroundBrush () const
 Gets value of BackgroundBrushProperty. More...
 
void setBackgroundBrush (BrushSharedPtr value)
 Sets value of BackgroundBrushProperty. More...
 
BrushSharedPtr getCompositionBrush () const
 Gets value of CompositionBrushProperty. More...
 
void setCompositionBrush (BrushSharedPtr value)
 Sets value of CompositionBrushProperty. More...
 
BrushSharedPtr getForegroundBrush () const
 Gets value of ForegroundBrushProperty. More...
 
void setForegroundBrush (BrushSharedPtr value)
 Sets value of ForegroundBrushProperty. More...
 
BrushRenderergetBackgroundBrushRenderer () const
 Get background brush renderer. More...
 
BrushRenderergetForegroundBrushRenderer () const
 Get foreground brush renderer. More...
 
BrushRenderergetCacheChildrenBrushRenderer () const
 Access cache children brush renderer. More...
 
BrushRenderergetCacheSelfBrushRenderer () const
 Access cache self brush renderer. More...
 
BrushRenderergetCompositionBrushRenderer () const
 Access cache result brush renderer. More...
 
SRTValue2D getRenderTransformation () const
 Gets the value of RenderTransformationProperty. More...
 
void setRenderTransformation (SRTValue2D value)
 Sets the value of RenderTransformationProperty. More...
 
SRTValue3D getPerspectiveTransformation () const
 Gets the value of PerspectiveTransformationProperty. More...
 
void setPerspectiveTransformation (SRTValue3D value)
 Sets the value of PerspectiveTransformationProperty. More...
 
void render (Renderer3D &renderer, CompositionStack &compositionStack)
 Render individual 2D node. More...
 
NodeVisual2DgetVisual () const
 Access visual component. More...
 
TextureSharedPtr getRenderTarget () const
 Gets value of RenderTargetProperty. More...
 
void setRenderTarget (TextureSharedPtr texture)
 Sets value of RenderTargetProperty. More...
 
TextureSharedPtr getFinalCompositionTarget () const
 Returns composition target combining all Node2D content. More...
 
bool hasCacheChildren () const
 Tell if node should cache its children. More...
 
bool hasCacheChildrenCompositionTarget () const
 Tell if node has cache children composition target. More...
 
bool isCacheChildrenValid () const
 Tell if children cache is valid. More...
 
void resetCacheChildren ()
 Reset cached content for children. More...
 
bool hasCacheResult () const
 Tell if node should cache its result. More...
 
bool hasFinalCompositionTarget () const
 Tell if node has final composition target. More...
 
bool isCacheResultValid () const
 Tell if children cache is valid. More...
 
void resetCacheResult ()
 Reset cached content for complete node content including itself and its children. More...
 
bool hasCacheSelf () const
 Tell if node should cache itself. More...
 
bool hasCacheSelfCompositionTarget () const
 Tell if node has cache children composition target. More...
 
bool isCacheSelfValid () const
 Tell if children cache is valid. More...
 
void resetCacheSelf ()
 Reset cached content for node itself. More...
 
CompositionManagergetCompositionManager () const
 Access composition manager. More...
 
NodeCompositor2DgetCompositor () const
 Access compositor component. More...
 
void setAutoWidth ()
 Sets node to automatically determine width. More...
 
void setAutoHeight ()
 Sets node to automatically determine height. More...
 
void setAutoSize ()
 Sets node to automatically determine both width and height. More...
 
void setSize (float width, float height)
 Sets size properties of the node. More...
 
void setLayoutSize (float width, float height)
 Sets size properties of the node. More...
 
SRTValue2D getLayoutTransformation () const
 Gets the value of LayoutTransformationProperty. More...
 
void setLayoutTransformation (SRTValue2D value)
 Sets the value of LayoutTransformationProperty. More...
 
Vector2 getDesiredSize () const
 Get desired size. More...
 
void setDesiredSize (Vector2 size)
 Set desired size. More...
 
Vector2 getAllocatedSize () const
 Get allocated size. More...
 
void setAllocatedSize (Vector2 allocatedSize)
 Set allocated size. More...
 
Vector2 getActualSize () const
 Get actual size. More...
 
void setActualSize (Vector2 actualSize)
 Set actual size. More...
 
void setActualSize (float sizeX, float sizeY)
 Set actual size. More...
 
Matrix3x3 getArrangeTransform () const
 Get arrange transform. More...
 
void setArrangeTransform (Matrix3x3 transform)
 Set arrange transform. More...
 
void layout (optional< Matrix3x3 > rootTransform)
 Does layout pass starting from this node and iterating recursively all of its children. More...
 
void layout ()
 Does layout pass with no root transformation (identity). More...
 
bool measure (const Vector2 *availableSize, bool handleStretch)
 Measure one node. More...
 
virtual bool measureRecursive ()
 Perform measure recursively. More...
 
void arrange ()
 Arrange one Node2D. More...
 
void extract ()
 Extract one Node2D. More...
 
Matrix3x3 getWorldTransform () const
 Get world transform. More...
 
bool containsLocal (Vector2 point) const
 Tell if a node area contains a point (defined in node's own space). More...
 
optional< Vector2containsGlobal (Vector2 point) const
 Tell if a node area contains a point (defined in screen space). More...
 
optional< Vector2globalToLocal (Vector2 point) const
 
NodeSharedPtr hitTest (Vector2 point)
 Performs a hit test to a 2D node and all its child nodes. More...
 
NodeSharedPtr hitTest (Vector2 point, const Metaclass *type)
 Performs a hit test to a 2D node and all its child nodes. More...
 
NodeSharedPtr hitTestIterate (Vector2 point, HitTestVisitor visitor, void *userData)
 Recursively hit test nodes from this node downwards and call visitor function on nodes hit. More...
 
virtual tuple< NodeSharedPtr, KzcRay, float > hitTestContent (Vector2 point)
 Default implementation of Node2D content hit test. More...
 
template<typename T >
shared_ptr< T > hitTest (Vector2 point)
 Wrapper for hitTest(Vector2), casts the return value. More...
 
template<typename T >
shared_ptr< T > hitTest (Vector2 point, const Metaclass *type)
 Wrapper for hitTest(Vector2, const Metaclass), casts the return value. More...
 
virtual NodeSharedPtr findAbstractChildOverride (string_view name) KZ_OVERRIDE
 Node::findAbstractChildOverride() implementation. More...
 
virtual VisitorResult visitAbstractChildOverride (const Visitor &visitor, VisitorOrder order) KZ_OVERRIDE
 Node::visitAabstractChild implementation. More...
 
virtual bool addAbstractChildOverride (NodeSharedPtr child) KZ_OVERRIDE
 Node::addAbstractChildOverride() implementation. More...
 
virtual size_t getAbstractChildCountOverride () KZ_OVERRIDE
 Node::getAbstractChildCountOverride() implementation. More...
 
virtual NodeSharedPtr getAbstractChildOverride (size_t index) KZ_OVERRIDE
 Node::getAbstractChildOverride() implementation. More...
 
virtual bool removeAbstractChildOverride (Node &child) KZ_OVERRIDE
 Node::removeAbstractChildOverride() implementation. More...
 
bool compositionRequiresAlpha () const
 Tell if composition requires alpha. More...
 
void setCompositionRequiresAlpha (bool enabled)
 Turn composition alpha requirement on or off. More...
 
bool compositionRequiresDepth () const
 Tell if composition requires depth. More...
 
void setCompositionRequiresDepth (bool enabled)
 Turn composition depth requirement on or off. More...
 
bool compositionRequiresStencil () const
 Tell if composition requires stencil. More...
 
void setCompositionRequiresStencil (bool enabled)
 Turn composition stencil requirement on or off. More...
 
QuadDescription getBackgroundQuad () const
 Gets the background quad description. More...
 
ClippingArea getClippingArea () const
 Get clipping area. More...
 
float getLayoutOpacity () const
 Get opacity after propagation from layouting hierarchy. More...
 
Matrix3x3 getRenderQuadTransform () const
 Gets transformation used to render the 2D node. More...
 
bool hasCenterClipArea () const
 Tell if Node2D has the center clip area (the area of itself). More...
 
bool hasOutsideClipArea () const
 Tell if Node2D has outside clipping area. More...
 
bool hasTranslucentForeground () const
 Tell if Node2D foreground has translucency. More...
 
void setForegroundIsTranslucent (bool enabled)
 Set foreground translucency status. More...
 
void setFinalCompositionRequested (bool enabled)
 Turn composition request on or off. More...
 
bool isCompositionClearColorRequired () const
 Indicates whether composition target requires color clear before rendering. More...
 
bool isClearColorAllowed () const
 Indicates whether this Node2D is allowed and should clear the color buffer of its own composition target. More...
 
void setClearColorAllowed (bool enabled)
 Set clear color allowed. More...
 
bool isRenderChildrenAllowed () const
 Tell if rendering children is allowed. More...
 
bool isRenderSelfAllowed () const
 Tell if render self is allowed. More...
 
bool isVisibleForHitTesting () const
 Tell if Node2D is visible for hit testing. More...
 
bool requiresBackgroundBrushRendering () const
 Tell if background brush rendering is required. More...
 
bool requiresForegroundBrushRendering () const
 Tell if foreground brush rendering is required. More...
 
bool hasChildrenRequireExtract () const
 Tell if children require extract flag is on. More...
 
void setChildrenRequireExtract (bool enabled)
 Set children require extract flag. More...
 
bool requiresExtract () const
 Tell if node requires extraction. More...
 
void setRequiresExtract (bool enabled)
 Turn extract requirement on or off. More...
 
bool isSelfInCompositionTarget () const
 Tell if node itself is going to get rendered into a composition target. More...
 
Vector2 getContentDesiredSize () const
 Get size desired by content. More...
 
Vector2 getSecondPassDesiredSize () const
 Get second pass desired size. More...
 
Vector2 getUserDesiredSize () const
 Get size desired by user. More...
 
Matrix3x3 getPartialArrangeTransform () const
 Get partial arrange transform. More...
 
- Public Member Functions inherited from kanzi::Node
virtual ~Node ()
 Destructor. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property. More...
 
AbstractPropertyTypeDescriptor::ValueSourcegetNodeFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
DataType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::DataType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename TMessageType , typename TClass , typename TClassMethod >
MessageSubscriptionToken addMessageHandler (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method)
 Adds a message handler where handler is a method to invoke on an object. More...
 
template<typename TMessageType , typename TClass , typename TClassMethod >
MessageSubscriptionToken addMessageFilter (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method)
 Adds a message filter where filter is a method to invoke on an object. More...
 
template<typename TMessageType >
MessageSubscriptionToken addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function)
 Adds a message handler where handler is function. More...
 
template<typename TMessageType >
MessageSubscriptionToken addMessageFilter (const TMessageType &messageType, typename TMessageType::FunctionType function)
 Adds a message filter where filter is function. More...
 
template<typename TMessageType >
MessageSubscriptionToken addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function, Node *messageSourceFilter)
 Adds a message handler where handler is function and accepted source is explicitly defined. More...
 
void removeMessageHandler (MessageSubscriptionToken token)
 Removes a message subscription. More...
 
template<typename TArgumentsType >
void dispatchMessage (const MessageType< TArgumentsType > &messageType, typename MessageType< TArgumentsType >::ArgumentsType &messageArguments)
 Dispatches a message with specified arguments. More...
 
void addResource (const ResourceID &resourceId, string_view resourceUrl)
 Adds a resource manager resource to an object node. If resourceID already exists in object, removes the existing entry. If resourceURL is NULL, error is thrown. */. More...
 
void removeResource (const ResourceID &resourceId)
 Removes a resource with given ID from object node resource dictionary. Does not do anything if resourceID was not found. */. More...
 
bool containsResource (const ResourceID &resourceID) const
 Returns if object node resource dictionary contains the resource with given ID. Resource can be any type: style, alias or resource manager resource. */. More...
 
optional< string > findResourceURL (const ResourceID &resourceId) const
 Tries to find Resource URL for Resource ID from this node. More...
 
ResourceSharedPtr acquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary. More...
 
template<typename T >
shared_ptr< T > acquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary, and casts the resource to given type. More...
 
ResourceSharedPtr tryAcquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary. More...
 
ResourceManager::AcquireTaskSharedPtr acquireResourceAsync (const ResourceID &key, ResourceManager::AsyncAcquireFinishedCallback func) const
 Posts an asynchronous task to acquire a resource. More...
 
template<typename T >
shared_ptr< T > tryAcquireResource (const ResourceID &id) const
 Acquires a resource from the node or the node's closest ancestor having the resource and casts the resource to given type. More...
 
ResourceDictionarySharedPtr getResourceDictionary () const
 Gets the resource dictionary of the node, if the node has one. More...
 
ResourceDictionarySharedPtr acquireResourceDictionary ()
 Gets the resource dictionary of the node. More...
 
void notifyResourceDictionaryModified ()
 Forces the re-evaluation of resource IDs in a node tree. More...
 
void setResourceDictionary (ResourceDictionarySharedPtr resourceDictionary)
 Replaces the resource dictionary of the node. More...
 
void addResourceDictionary (ResourceDictionarySharedPtr resourceDictionary)
 Add a nested resource dictionary to the resource dictionary of the node. More...
 
void addAnonymousResource (ResourceSharedPtr resource)
 Adds alias resource to an object node. More...
 
void removeAnonymousResource (const Resource &resource)
 Removes anonymous resource from object node resources. More...
 
bool isNamed (string_view name) const
 
NodegetParent () const
 Returns the parent of the node. More...
 
void setParent (Node *parent)
 
VisitorResult visit (const Visitor &visitor, VisitorOrder order)
 
VisitorResult visitDescendants (const Visitor &visitor, VisitorOrder order)
 
template<typename Type >
shared_ptr< Type > lookupNode (string_view pathOrKey)
 Returns a node of specified type by looking it up with specified path or alias. More...
 
NodelookupNodeRaw (string_view relativePath)
 Get an object node by another node and a relative path. More...
 
ObjectSharedPtr lookupObject (string_view relativePath)
 Lookup for an object from a node. More...
 
tuple< NodeSharedPtr, AbstractPropertyTypelookupObjectForStateManager (string_view relativePath)
 Lookup for an node and possible object from within the node for state manager. More...
 
template<typename Type >
shared_ptr< Type > lookupObject (string_view path)
 Lookup for an object from a node. More...
 
template<typename TNodeType >
shared_ptr< TNodeType > findAbstractChild (string_view name)
 Find a child by name. Finds direct children as well as children connected indirectly for example Viewport->Scene. More...
 
void addInputManipulator (InputManipulatorSharedPtr inputManipulator)
 Transfers the ownership and attaches an input manipulator to an object node. More...
 
void removeInputManipulator (InputManipulator &inputManipulator)
 Removes the ownership and detaches an input manipulator from an object node. More...
 
InputManipulatorConstIterator beginInputManipulators () const
 
InputManipulatorConstIterator endInputManipulators () const
 
void addBinding (BindingSharedPtr binding)
 Transfers the ownership of a binding rule to an object node. More...
 
void addBindingWithOwner (BindingSharedPtr binding, shared_ptr< void > owner)
 Transfers the ownership of a binding rule to an object node and sets the owner of binding rule. More...
 
void removeBinding (Binding &binding)
 Removes the ownership and detaches a binding rule from an object node. More...
 
void removeBindingsWithOwner (shared_ptr< void > owner)
 Removes all bindings with the specified owner. More...
 
BindingConstIterator beginBindings () const
 
BindingConstIterator endBindings () const
 
void addNodeComponent (NodeComponentSharedPtr nodeComponent)
 Transfers the ownership of a node component to an object node. More...
 
void addNodeComponentWithOwner (NodeComponentSharedPtr nodeComponent, const void *owner)
 Transfers the ownership of a node component to an object node and sets the owner of the node component. More...
 
void removeNodeComponent (NodeComponent &nodeComponent)
 Removes the ownership of a node component from an object node. More...
 
void removeNodeComponentWithOwner (const void *owner)
 Removes all bindings with the specified owner. More...
 
NodeComponentConstIterator beginNodeComponents () const
 
NodeComponentConstIterator endNodeComponents () const
 
template<typename Type >
shared_ptr< Type > lookupNodeComponent (string_view name)
 Returns a node component of specified type by looking it up with specified name. More...
 
void setRenderable (bool state)
 Sets whether the object node is renderable. More...
 
bool isRenderable () const
 Returns whether node is renderable. More...
 
bool isEffectivelyVisible () const
 Checks if the node and all of its ancestors are visible. More...
 
bool isEffectivelyEnabled () const
 Checks if the node and all of its ancestors are enabled. More...
 
uint32_t getChangeFlags () const
 Get current change flags. More...
 
uint32_t getChildChangeFlags () const
 Get current child change flags. More...
 
void setChangeFlag (uint32_t flag)
 Sets a change flag. More...
 
void clearChangeFlag (uint32_t flag)
 Clears a change flag. More...
 
bool isChangeFlagSet (uint32_t flag) const
 Checks if a change flag is set. More...
 
bool isAnyChangeFlagSet (uint32_t flag) const
 Checks if any of given flags is set. More...
 
void setChildChangeFlag (uint32_t flag)
 Sets a child change flag. More...
 
void clearChildChangeFlag (uint32_t flag)
 Clears a child change flag. More...
 
bool isChildChangeFlagSet (uint32_t flag) const
 Checks if child change flags match. More...
 
bool isAnyChildChangeFlagSet (uint32_t flag) const
 Checks if any child change flags (corresponding to given mask) are set. More...
 
bool isInvalidMeasure () const
 Check if the node needs measure. More...
 
void invalidateMeasure ()
 Invalidates measure for the node. More...
 
void validateMeasure ()
 Validates measure for the node. More...
 
bool isInvalidArrange () const
 Checks if the node needs arrange. More...
 
void invalidateArrange ()
 Invalidates arrange. More...
 
void validateArrange ()
 Validates arrange. More...
 
bool isInvalidRender () const
 Returns if node render flag is invalid. More...
 
void validateRender ()
 Validates render for node. More...
 
void invalidateRender ()
 Invalidates render for node. More...
 
bool isInvalidFinalTransform () const
 Tells if final transform flag is invalid for node. More...
 
void invalidateFinalTransform ()
 Invalidates final transform for node. More...
 
bool isInvalidDraw ()
 Tells if node draw flag is invalid. More...
 
void invalidateDraw ()
 Invalidates draw flag for the node. More...
 
void validateDraw ()
 Validates draw flags for the node. More...
 
void validateDrawForChildrenRecursive ()
 Recursively validates draw for the children from this 2D node onwards. More...
 
bool isInitialized () const
 Returns true if initialize() has been called, false otherwise. More...
 
bool isAttached () const
 Returns true if the node is attached to a screen or one of its descendants. More...
 
bool isAttaching () const
 Returns true if node is in the process of attaching, false otherwise. More...
 
bool isDetaching () const
 Returns true if the node currently detaching. More...
 
void attachRecursive ()
 Attaches an object node and its children recursively. More...
 
void detachRecursive ()
 Detaches an object node and its children recursively. More...
 
virtual const KzuBoundingVolumegetBoundingVolume () const
 Gets bounding volume from object node. More...
 
AppliedStyleEntrySharedPtr applyStyle (StyleSharedPtr style)
 Applies a style to an object node. More...
 
AppliedStyleEntrySharedPtr applyManualStyle (StyleSharedPtr style)
 Applies a style to an object node. More...
 
void unapplyStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 Unapplies a style from an object node. More...
 
void applyStyles ()
 Apply all styles for an object node. More...
 
void unapplyStyles ()
 Unapplies and removes all applied styles. More...
 
void applyStylesRecursive ()
 Applies styles recursively. More...
 
void unapplyStylesRecursive ()
 Unapplies styles recursively. More...
 
void removeKZBData ()
 Destroys all object node data loaded from KZB, including properties, bindings, node comopnents, resources etc. More...
 
void addResourceReference (AbstractPropertyType propertyType, AbstractResourceReference *reference)
 This is a helper for automatic resource tracking in ResourceReference. More...
 
void removeResourceReference (const AbstractResourceReference &reference)
 This is a helper for automatic resource tracking in ResourceReference. More...
 
void addNodeReference (AbstractPropertyType propertyType, AbstractNodeReference *reference)
 
void removeNodeReference (const AbstractNodeReference &reference)
 
ScriptingContextSharedPtr getScriptingContext () const
 
void setScriptingContext (ScriptingContextSharedPtr context)
 
void setTemplateRoot (NodeSharedPtr templateRoot)
 Sets the template root of this node. More...
 
NodeSharedPtr getTemplateRoot () const
 Gets the template root of this node. More...
 
bool trySetActiveFocus ()
 The method tries to move the active focus on this node. More...
 
string getName () const
 Gets the value of NameProperty. More...
 
void setName (string_view value)
 Sets the value of NameProperty. More...
 
string getPath () const
 Gets the value of PathProperty. More...
 
void setPath (string value)
 Sets the value of PathProperty. More...
 
string getLocale () const
 Gets the value of LocaleProperty. More...
 
void setLocale (string value)
 Sets the value of LocaleProperty. More...
 
bool isHitTestable () const
 Gets the value of HitTestableProperty. More...
 
void setHitTestable (bool value)
 Sets the value of HitTestableProperty. More...
 
bool isHitTestableContainer () const
 Gets the value of HitTestableContainerProperty. More...
 
void setHitTestableContainer (bool value)
 Sets the value of HitTestableContainerProperty. More...
 
bool isVisible () const
 Gets the value of VisibleProperty. More...
 
void setVisible (bool value)
 Sets the value of VisibleProperty. More...
 
bool isEnabled () const
 Gets the value of EnabledProperty. More...
 
void setEnabled (bool value)
 Sets the value of EnabledProperty. More...
 
bool isFocusable () const
 Gets the value of FocusableProperty. More...
 
void setFocusable (bool value)
 Sets the value of FocusableProperty. More...
 
bool isFocused () const
 Gets the value of FocusedProperty. More...
 
void setFocused (bool value)
 Sets the value of FocusedProperty. More...
 
bool hasLogicalFocus () const
 Returns the #LogicalFocusedProperty value. More...
 
void setLogicalFocus (bool value)
 Sets the value of LogicalFocusProperty. More...
 
FontSharedPtr getFont () const
 Gets the value of FontProperty. More...
 
void setFont (FontSharedPtr value)
 Sets the value of FontProperty. More...
 
float getVisibleAmountInParent () const
 Gets the value of VisibleAmountInParentProperty. More...
 
void setVisibleAmountInParent (float value)
 Sets the value of VisibleAmountInParentProperty. More...
 
float getProjection2DTo3DScale () const
 Gets the value of Projection2DTo3DScaleProperty. More...
 
void setProjection2DTo3DScale (float value)
 Sets the value of Projection2DTo3DScaleProperty. More...
 
bool isEnableClick () const
 Gets the value of EnableClickProperty. More...
 
void setEnableClick (bool value)
 Sets the value of EnableClickProperty. More...
 
bool isEnableMultiClick () const
 Gets the value of EnableMultiClickProperty. More...
 
void setEnableMultiClick (bool value)
 Sets the value of EnableMultiClickProperty. More...
 
ResourceSharedPtr getStyle () const
 Gets the value of StyleProperty. More...
 
void setStyle (ResourceSharedPtr value)
 Sets the value of StyleProperty. More...
 
ResourceSharedPtr getStateManager () const
 Gets the value of StateManagerProperty. More...
 
void setStateManager (ResourceSharedPtr value)
 Sets the value of StateManagerProperty. More...
 
float getWidth () const
 Gets the value of WidthProperty. More...
 
void setWidth (float value)
 Sets the value of WidthProperty. More...
 
float getHeight () const
 Gets the value of HeightProperty. More...
 
void setHeight (float value)
 Sets the value of HeightProperty. More...
 
float getDepth () const
 Gets the value of DepthProperty. More...
 
void setDepth (float value)
 Sets the value of DepthProperty. More...
 
float getActualWidth () const
 Gets the value of ActualWidthProperty. More...
 
void setActualWidth (float value)
 Sets the value of ActualWidthProperty. More...
 
float getActualHeight () const
 Gets the value of ActualHeightProperty. More...
 
void setActualHeight (float value)
 Sets the value of ActualHeightProperty. More...
 
float getActualDepth () const
 Gets the value of ActualDepthProperty. More...
 
void setActualDepth (float value)
 Sets the value of ActualDepthProperty. More...
 
Node::HorizontalAlignment getHorizontalAlignment () const
 Gets the value of HorizontalAlignmentProperty. More...
 
void setHorizontalAlignment (Node::HorizontalAlignment value)
 Sets the value of HorizontalAlignmentProperty. More...
 
Node::VerticalAlignment getVerticalAlignment () const
 Gets the value of VerticalAlignmentProperty. More...
 
void setVerticalAlignment (Node::VerticalAlignment value)
 Sets the value of VerticalAlignmentProperty. More...
 
Node::DepthAlignment getDepthAlignment () const
 Gets the value of DepthAlignmentProperty. More...
 
void setDepthAlignment (Node::DepthAlignment value)
 Sets the value of DepthAlignmentProperty. More...
 
Vector2 getHorizontalMargin () const
 Gets the value of HorizontalMarginProperty. More...
 
void setHorizontalMargin (Vector2 value)
 Sets the value of HorizontalMarginProperty. More...
 
Vector2 getVerticalMargin () const
 Gets the value of VerticalMarginProperty. More...
 
void setVerticalMargin (Vector2 value)
 Sets the value of VerticalMarginProperty. More...
 
Vector2 getDepthMargin () const
 Gets the value of DepthMarginProperty. More...
 
void setDepthMargin (Vector2 value)
 Sets the value of DepthMarginProperty. More...
 
Node::ContentStretch getContentStretch () const
 Gets the value of ContentStretchProperty. More...
 
void setContentStretch (Node::ContentStretch value)
 Sets the value of ContentStretchProperty. More...
 
float getOpacity () const
 Gets the value of OpacityProperty. More...
 
void setOpacity (float value)
 Sets the value of OpacityProperty. More...
 
bool isClipChildren () const
 Gets the value of ClipChildrenProperty. More...
 
void setClipChildren (bool value)
 Sets the value of ClipChildrenProperty. More...
 
- Public Member Functions inherited from kanzi::Object
 Object (Domain *domain)
 
virtual ~Object ()
 
DomaingetDomain () const
 Returns the domain the object belongs to. More...
 
KzuTaskSchedulergetTaskScheduler () const
 Returns the task scheduler of the object. More...
 
KzuMessageDispatchergetMessageDispatcher () const
 Returns the message dispatcher of the object. More...
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object. More...
 
virtual const MetaclassgetDynamicMetaclass () const KZ_OVERRIDE
 Returns the metaclass of the dynamic type of the object. More...
 
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object. More...
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void applyObjectStyles ()
 Apply all styles for an object node. More...
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles. More...
 
- Public Member Functions inherited from kanzi::MetaObject
virtual ~MetaObject ()
 
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it. More...
 
- Public Member Functions inherited from kanzi::PropertyObject
 PropertyObject ()
 
virtual ~PropertyObject ()
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property. More...
 
void removeKzbProperties ()
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property. More...
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers. More...
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value. More...
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers. More...
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property. More...
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property. More...
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property. More...
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object. More...
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object. More...
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *owner)
 
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
void validatePropertyModifiers (AbstractPropertyType propertyType)
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType)
 Gets number of current notification handlers for given property type. More...
 

Static Public Member Functions

static float layoutUp ()
 
static bool isValidLayoutSize (Vector2 size)
 Indicates whether a size is valid layout size. More...
 
static Vector2 unboundedLayoutSize ()
 Returns an unbounded layout size. More...
 
static bool isUnboundedLayoutSize (Vector2 layoutSize)
 Indicates whether a layout size is an unbound layout size. More...
 
static Vector2 replaceUnboundedLayoutSize (Vector2 layoutSize, Vector2 resetSize)
 Replaces any element of a layout size with appropriate element of the reset size if it is unbounded and returns the size. More...
 
static Vector2 replaceUnboundedLayoutSizeWithZero (Vector2 layoutSize)
 Replaces any element of a layout size with zero if it is unbounded and returns the size. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 
- Static Public Member Functions inherited from kanzi::Node
static bool isValidLayoutValue (float value)
 Indicates whether a value is valid layout value. More...
 
static float unboundedLayoutValue ()
 Returns an unbounded layout value. More...
 
static bool isUnboundedLayoutValue (float layoutValue)
 Indicates whether a value is an unbound layout value. More...
 
static float replaceUnboundedLayoutValue (float layoutValue, float resetValue)
 Replaces layout value with the specified value if it is unbounded and returns it. More...
 
static float replaceUnboundedLayoutValueWithZero (float layoutValue)
 Replaces layout value with zero if it is unbounded layout value and returns it. More...
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 

Protected Types

enum  Node2DFlags {
  AllowClear, AllowRenderChildren, AllowRenderSelf, ForegroundIsTranslucent,
  ForegroundTranslucencyRequested, RequiresBackgroundQuad, RequiresExtract, ChildrenRequireExtract,
  Node2DFlagsBitCount
}
 Different Node2D flags for bit set. More...
 
- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container. More...
 

Protected Member Functions

 Node2D (Domain *domain, string_view name)
 Constructor. More...
 
void initialize ()
 
NodeVisual2DacquireVisual ()
 Initializes and returns visual structure. More...
 
virtual void renderOverride (Renderer3D &renderer, CompositionStack &compositionStack)
 Node-specific top-level render call. More...
 
void renderRecursive (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Render a Node2D and then recursively all its children. More...
 
virtual void renderSelfOverride (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Node-specific rendering. More...
 
void renderChildren (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Render all children of a Node2D. More...
 
void renderBackground (Renderer3D &renderer, const CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Render background quad of a Node2D. More...
 
void renderForeground (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Render foreground of a Node2D. More...
 
virtual void renderForegroundOverride (Renderer3D &renderer, CompositionStack &compositionStack, const Matrix3x3 &baseTransform)
 Node-specific foreground render. More...
 
bool pushLocalViewportArea (CompositionStack &compositionStack)
 Push local viewport and scissor area into composition stack if it's required. More...
 
NodeCompositor2DacquireCompositor ()
 Initializes and returns composition structure. More...
 
void clearCompositionTarget (Renderer3D &renderer, CompositionStack &compositionStack, bool clearColor)
 Clear node render target. More...
 
virtual Vector2 measureOverride (Vector2 availableSize)
 Default implementation of Node2D size calculation. More...
 
virtual void arrangeRecursive (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform, bool arrangeNeeded, bool transformChanged)
 Perform arrange recursively. More...
 
virtual void arrangeOverride (Vector2 actualSize)
 Default implementation of Node2D arrange. More...
 
optional< float > getUserAspectRatio () const
 Get aspect ratio property assigned to the node. More...
 
optional< float > getUserHeight () const
 Get layout height property assigned to the node. More...
 
optional< float > getUserWidth () const
 Get layout width property assigned to the node. More...
 
Vector2 getDesiredSizeAxisAlignedBoundingBoxMinimum () const
 Get desired size axis aligned bounding box minimum. More...
 
void setDesiredSizeAxisAlignedBoundingBoxMinimum (Vector2 size)
 Set desired size axis aligned bounding box minimum. More...
 
void setDesiredSizeAxisAlignedBoundingBoxMinimum (float sizeX, float sizeY)
 Set desired size axis aligned bounding box minimum. More...
 
Vector2 getDesiredSizeAxisAlignedBoundingBoxMaximum () const
 Get desired size axis aligned bounding box maximum. More...
 
void setDesiredSizeAxisAlignedBoundingBoxMaximum (Vector2 size)
 Set desired size axis aligned bounding box maximum. More...
 
void setDesiredSizeAxisAlignedBoundingBoxMaximum (float sizeX, float sizeY)
 Set desired size maximum. More...
 
void calculateTransformedBoundingArea (const Matrix3x3 &transform, Vector2 sizeIn)
 Calculate new transformed bounding area. More...
 
Matrix3x3 updateFinalTransform (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform)
 Update final transformation. More...
 
bool updateRender (const Matrix3x3 &worldTransform, const Matrix3x3 &parentTransform, bool transformChanged)
 Validate node for rendering. More...
 
virtual void updateRenderOverride ()
 Node-specific updates done before render. More...
 
optional< QuadDescriptioncalculateContentStretch (Vector2 renderSize, Vector2 contentSize)
 Calculate content stretch. More...
 
ClippingArea calculateClippingArea (const Matrix3x3 &parentSpaceTransform) const
 Calculate clipping parameters. More...
 
unsigned int performClipping (QuadDescription &backgroundQuad, optional< QuadDescription > &foregroundQuad, unsigned int clippingResult)
 Perform rectangle clipping. More...
 
void extractChildren () const
 Extract children of node, called from extraction implementations. More...
 
virtual void onExtract ()
 Node2D extract function. More...
 
virtual void onDetached () KZ_OVERRIDE
 Node::onDetached() implementation. More...
 
virtual void onNodePropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) KZ_OVERRIDE
 Node::onNodePropertyChanged implementation. More...
 
virtual void restoreResources () KZ_OVERRIDE
 Node::restoreResources() implementation. More...
 
bool isCompletelyClipped () const
 Tell if node is completely clipped (and needs not be rendered). More...
 
bool isCompletelyTransparent () const
 Tell if node is completely transparent. More...
 
bool isEmptyActualSize () const
 Tell if the size of the node is empty or invalid. More...
 
bool isForegroundHintOpaque () const
 Tell if foreground hint is opaque. More...
 
bool isForegroundHintTranslucent () const
 Tell if foreground hint is translucent. More...
 
bool isForegroundTranslucencyRequested () const
 Tell if foreground translucency has been requested. More...
 
void setForegroundTranslucencyRequested (bool enabled)
 Turn foreground translucency request on or off. More...
 
void setPartialArrangeTransform (Matrix3x3 transform)
 Sets partial arrange transform. More...
 
void setRenderChildrenAllowed (bool enabled)
 Turn render children on or off. More...
 
void setRenderSelfAllowed (bool enabled)
 Turn render self on or off. More...
 
void setRenderType (RenderType renderType)
 Set render type. More...
 
void updateContentTexture (TextureSharedPtr texture)
 Update content texture for the foreground brush. More...
 
void setSecondPassDesiredSize (Vector2 size)
 Set second pass desired size. More...
 
- Protected Member Functions inherited from kanzi::Node
 Node (Domain *domain, string_view name)
 Constructor. More...
 
void initialize ()
 
virtual void onAttached ()
 Called when an object node becomes attached. More...
 
void updatePropertiesForConnectedNode ()
 Invokes property notifications for inherited properties during scene graph tree connections. More...
 
void updatePropertiesForDisconnectedNode (Node *oldParent)
 Invokes property notifications for inherited properties during scene graph tree disconnections. More...
 
void updateResourceReferences ()
 
void updateResourceReferences (AbstractPropertyType propertyType)
 
void updateResourceReferencesRecursive ()
 
void updateResourceReferencesRecursive (const ResourceID &resourceID)
 
void attach ()
 Attaches the object node. More...
 
void detach ()
 Detaches the object node. More...
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &propertyStorage, PropertyNotificationReason reason) KZ_OVERRIDE
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
 MetaObject ()
 
void initialize ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *owner)
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 
AbstractPropertyTypeDescriptor::ValueSourceEntrygetTopValueSourceEntry (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage) const
 
AbstractPropertyTypeDescriptor::ValueSourceEntrygetTopValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourceEntryfindLocalValueSourceEntry (AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer that can be used to hold a reference until end of operation. More...
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType)
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 Copy local value from property storage. More...
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 
PropertyStorageContainer::iterator endPropertyStorage ()
 
void onCopy (const PropertyObject &other)
 

Protected Attributes

unique_ptr< NodeVisual2Dm_visual
 Visual information. More...
 
unique_ptr< NodeCompositor2Dm_compositor
 Composition and caching information. More...
 
QuadDescription m_backgroundQuadDescription
 Background clipping quad / composition quad description. More...
 
ClippingArea m_clipping
 Clipping parameters. More...
 
CompositionRequirements m_compositionRequirements
 Composition requirements for this 2D node. More...
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object. More...
 

Friends

class Screen
 
class Viewport3D
 
void doListBoxArrange (Node2D &node)
 

Properties

static PropertyType< float > AspectRatioProperty
 AspectRatio property. More...
 
static PropertyType< bool > ForceCompositionProperty
 ForceComposition property. More...
 
static PropertyType< Node2D::ForegroundHintForegroundHintProperty
 ForegroundHint property. More...
 
static PropertyType< bool > CacheChildrenProperty
 CacheChildren property. More...
 
static PropertyType< bool > CacheResultProperty
 CacheResult property. More...
 
static PropertyType< bool > CacheSelfProperty
 CacheSelf property. More...
 
static PropertyType< bool > OffscreenRenderingProperty
 OffscreenRendering property. More...
 
static PropertyType< bool > DisableRenderTargetClearProperty
 DisableRenderTargetClear property. More...
 
static PropertyType< Node2D::PixelFormatPixelFormatProperty
 PixelFormat property. More...
 
static PropertyType< bool > RenderSelfProperty
 RenderSelf property. More...
 
static PropertyType< ResourceSharedPtrRenderTargetProperty
 RenderTarget property. More...
 
static PropertyType< float > RenderTargetMinimumHeightProperty
 RenderTargetMinimumHeight property. More...
 
static PropertyType< float > RenderTargetMinimumWidthProperty
 RenderTargetMinimumWidth property. More...
 
static PropertyType< float > RenderTargetReallocationLimitProperty
 RenderTargetReallocationLimit property. More...
 
static PropertyType< SRTValue2DLayoutTransformationProperty
 LayoutTransformation property. More...
 
static PropertyType< SRTValue2DRenderTransformationProperty
 RenderTransformation property. More...
 
static PropertyType< SRTValue3DPerspectiveTransformationProperty
 PerspectiveTransformation property. More...
 
static PropertyType< Vector2RenderTransformationOriginProperty
 RenderTransformationOrigin property. More...
 
static PropertyType< bool > SnapToPixelProperty
 SnapToPixel property. More...
 
static PropertyType< ResourceSharedPtrBackgroundBrushProperty
 BackgroundBrush property. More...
 
static PropertyType< ResourceSharedPtrCompositionBrushProperty
 CompositionBrush property. More...
 
static PropertyType< ResourceSharedPtrForegroundBrushProperty
 ForegroundBrush property. More...
 
float getAspectRatio () const
 Gets the value of AspectRatioProperty. More...
 
void setAspectRatio (float value)
 Sets the value of AspectRatioProperty. More...
 
bool isForceComposition () const
 Gets the value of ForceCompositionProperty. More...
 
void setForceComposition (bool value)
 Sets the value of ForceCompositionProperty. More...
 
Node2D::ForegroundHint getForegroundHint () const
 Gets the value of ForegroundHintProperty. More...
 
void setForegroundHint (Node2D::ForegroundHint value)
 Sets the value of ForegroundHintProperty. More...
 
bool isCacheChildren () const
 Gets the value of CacheChildrenProperty. More...
 
void setCacheChildren (bool value)
 Sets the value of CacheChildrenProperty. More...
 
bool isCacheResult () const
 Gets the value of CacheResultProperty. More...
 
void setCacheResult (bool value)
 Sets the value of CacheResultProperty. More...
 
bool isCacheSelf () const
 Gets the value of CacheSelfProperty. More...
 
void setCacheSelf (bool value)
 Sets the value of CacheSelfProperty. More...
 
bool isOffscreenRendering () const
 Gets the value of OffscreenRenderingProperty. More...
 
void setOffscreenRendering (bool value)
 Sets the value of OffscreenRenderingProperty. More...
 
bool isDisableRenderTargetClear () const
 Gets the value of DisableRenderTargetClearProperty. More...
 
void setDisableRenderTargetClear (bool value)
 Sets the value of DisableRenderTargetClearProperty. More...
 
Node2D::PixelFormat getPixelFormat () const
 Gets the value of PixelFormatProperty. More...
 
void setPixelFormat (Node2D::PixelFormat value)
 Sets the value of PixelFormatProperty. More...
 
bool isRenderSelf () const
 Gets the value of RenderSelfProperty. More...
 
void setRenderSelf (bool value)
 Sets the value of RenderSelfProperty. More...
 
float getRenderTargetMinimumHeight () const
 Gets the value of RenderTargetMinimumHeightProperty. More...
 
void setRenderTargetMinimumHeight (float value)
 Sets the value of RenderTargetMinimumHeightProperty. More...
 
float getRenderTargetMinimumWidth () const
 Gets the value of RenderTargetMinimumWidthProperty. More...
 
void setRenderTargetMinimumWidth (float value)
 Sets the value of RenderTargetMinimumWidthProperty. More...
 
float getRenderTargetReallocationLimit () const
 Gets the value of RenderTargetReallocationLimitProperty. More...
 
void setRenderTargetReallocationLimit (float value)
 Sets the value of RenderTargetReallocationLimitProperty. More...
 
Vector2 getRenderTransformationOrigin () const
 Gets the value of RenderTransformationOriginProperty. More...
 
void setRenderTransformationOrigin (Vector2 value)
 Sets the value of RenderTransformationOriginProperty. More...
 
bool isSnapToPixel () const
 Gets the value of SnapToPixelProperty. More...
 
void setSnapToPixel (bool value)
 Sets the value of SnapToPixelProperty. More...
 

Additional Inherited Members

- Static Public Attributes inherited from kanzi::Node
static PropertyType< string > NameProperty
 Name property. More...
 
static PropertyType< string > PathProperty
 Path property. More...
 
static PropertyType< string > LocaleProperty
 Locale property. More...
 
static PropertyType< bool > CreatedFromKZBProperty
 CreatedFromKZB property. More...
 
static PropertyType< bool > HitTestableProperty
 HitTestable property. More...
 
static PropertyType< bool > HitTestableContainerProperty
 HitTestableContainer property. More...
 
static PropertyType< bool > VisibleProperty
 Visible property. More...
 
static PropertyType< bool > EnabledProperty
 Enabled property. More...
 
static PropertyType< bool > FocusableProperty
 The property specifies whether a node can get active focus and can participate in the focus chain navigation. More...
 
static PropertyType< bool > FocusedProperty
 Specifies that the node is the active focus node, which receives keyboard messages. More...
 
static PropertyType< bool > LogicalFocusProperty
 Specifies that the node has logical focus state. More...
 
static PropertyType< ResourceSharedPtrFontProperty
 Font property. More...
 
static PropertyType< float > VisibleAmountInParentProperty
 VisibleAmountInParent property. More...
 
static PropertyType< float > Projection2DTo3DScaleProperty
 Projection2DTo3DScale property. More...
 
static PropertyType< bool > EnableClickProperty
 EnableClick property. More...
 
static PropertyType< bool > EnableMultiClickProperty
 EnableMultiClick property. More...
 
static PropertyType< ResourceSharedPtrStyleProperty
 Style property. More...
 
static PropertyType< ResourceSharedPtrStateManagerProperty
 StateManager property. More...
 
static PropertyType< void * > PrefabTemplateSourceProperty
 PrefabTemplateSource property. More...
 
static PropertyType< float > WidthProperty
 Width property. More...
 
static PropertyType< float > HeightProperty
 Height property. More...
 
static PropertyType< float > DepthProperty
 Depth property. More...
 
static PropertyType< float > ActualWidthProperty
 ActualWidth property. More...
 
static PropertyType< float > ActualHeightProperty
 ActualHeight property. More...
 
static PropertyType< float > ActualDepthProperty
 ActualDepth property. More...
 
static PropertyType< Node::HorizontalAlignmentHorizontalAlignmentProperty
 HorizontalAlignment property. More...
 
static PropertyType< Node::VerticalAlignmentVerticalAlignmentProperty
 VerticalAlignment property. More...
 
static PropertyType< Node::DepthAlignmentDepthAlignmentProperty
 DepthAlignment property. More...
 
static PropertyType< Vector2HorizontalMarginProperty
 HorizontalMargin property. More...
 
static PropertyType< Vector2VerticalMarginProperty
 VerticalMargin property. More...
 
static PropertyType< Vector2DepthMarginProperty
 DepthMargin property. More...
 
static PropertyType< Node::ContentStretchContentStretchProperty
 ContentStretch property. More...
 
static PropertyType< float > OpacityProperty
 Opacity property. More...
 
static PropertyType< bool > ClipChildrenProperty
 ClipChildren property. More...
 
static PropertyType< int > SceneGraphAddNodeChangeChildFlagsProperty
 SceneGraphAddNodeChangeChildFlags property. More...
 
static PropertyType< int > SceneGraphAddNodeChangeParentFlagsProperty
 SceneGraphAddNodeChangeParentFlags property. More...
 
static PropertyType< int > SceneGraphRemoveNodeChangeChildFlagsProperty
 SceneGraphRemoveNodeChangeChildFlags property. More...
 
static PropertyType< int > SceneGraphRemoveNodeChangeParentFlagsProperty
 SceneGraphRemoveNodeChangeParentFlags property. More...
 
- Static Protected Member Functions inherited from kanzi::Node
static VisitorResult updateResourceVisitor (Node &node, const ResourceID &id)
 
static VisitorResult updateAllResourcesVisitor (Node &node)
 
static VisitorResult applyStylesVisitor (Node &node, bool apply)
 
static VisitorResult attachVisitor (Node &node)
 
static VisitorResult detachVisitor (Node &node)
 
static VisitorResult validateDrawVisitor (Node &node)
 Visitor for validating draw. More...
 
static bool processPropertyChanged (Node &node, AbstractPropertyType propertyType, const PropertyStoragePtr &nodePropertyStorage, AbstractPropertyTypeDescriptor::PropertyStorage *changedPropertyStorage, PropertyNotificationReason reason)
 Processes notification handlers for node and property storage. More...
 
static VisitorResult propertyChangedVisitor (Node &node, AbstractPropertyType propertyType, AbstractPropertyTypeDescriptor::PropertyStorage *propertyStorage, PropertyNotificationReason reason)
 

Detailed Description

Node2D is the base class of all 2D nodes.

Node2D implements functionality common to all 2D nodes, such as rendering, layout and hit testing. You should use classes derived from Node2D like #Image2D, #EmptyNode2D and #StackLayout2D to construct UI graphs. You can derive from Node2D to implement your own custom rendering and layout.

You can configure common parameters for rendering and layout with methods of Node2D. Use methods of derived classes to control behavior specific to them.

Creating nodes

To construct 2D nodes, call a create functions that return a shared pointer to the node. You can create an empty node:

EmptyNode2DSharedPtr emptyNode = EmptyNode2D::create(domain, "empty node");

You can create an image node:

Image2DSharedPtr imageNode = Image2D::create(domain, "image node", texture);

Each node has its own type of create function.

Constructors of nodes are protected, and cannot be accessed except for inheriting classes. Node initialization happens within the create function, after constructing the node.

Node2D tree

Nodes are arranged to a scene graph. You may think of scene graphs as directed acyclic graphs with no loops. In other words, each scene graph is a tree. Each node may have multiple children but only one parent.

Scene graph root is always a 2D node. The root node does not have a parent, and is is usually of type Screen.

#Viewport2D nodes serve as windows to 3D scene graphs that are displayed in the viewport area. Viewport nodes have #Scene nodes as children. Scenes have #Node3D children.

Constructing the scene graph

You can manipulate the scene graph by adding children to nodes:

// Create and add a child node.
Node2DSharedPtr childNode = EmptyNode2D::create(domain, "child");
parentNode->addChild(childNode);

You can remove children from a parent node:

parentNode->removeChild(*childNode);

Parents take ownership, and hold a reference to the children.

Iterating the scene graph

You can explore the scene graph from a node by iterating its children:

for (Node2D::ChildConstIterator it = parentNode->beginChildren(); (it != parentNode->endChildren()); ++it)
{
// Get the name from current child and do something with it as an example.
stream << (*it)->getName() << "::";
}

You can also go upwards to the parent:

// Node2D will always have a parent of type Node2D.
Node2D* parent = dynamic_cast<Node2D*>(child1->getParent());

The parent returned is valid except for the root node that has no parent (it will return 0).

Finding nodes

Finding nodes in the scene graph is inherited from Node base class. You can look for nodes with a path:

// "parent" is a child of screen.
Node2DSharedPtr foundChild = screen->lookupNode<Node2D>("parent/child1");

The paths work relative from the node doing the lookup. You can also traverse upwards:

// "child1" is a child of "parent", which is a child of screen.
Node2DSharedPtr foundScreen = child1->lookupNode<Node2D>("../..");

If lookup fails, no node is returned. For details, refer to scene graph lookup in Node documentation.

Rendering

Rendering nodes happens from root node downwards, iterating the tree in depth-first algorithm.

Each node has a foreground and a background. Foreground and background are rendered separately. Node classes can override foreground or background rendering separately.

Foreground is the node content, for example an image. Background is the full node area. It may be the same size as the node content or larger. Fitting the content to the node area is controlled by ContentStretchProperty, for details, see section about content stretch.

Rendering order

Nodes are rendered in the order they were added to the parent node. Node added first will be rendered first You can modify the rendering order by reordering the children within the parent. You can move nodes to the front to render them last:

// child1 will now be rendered last, after other children of the parent.
child3->moveToFront();

You can move nodes to the back, to render them first:

// child3 will now be rendered first before other children of the parent.
child3->moveToBack();

Parent content is always rendered before rendering the children.

Brushes

Rendering of node foreground, background and optional composition happens using brushes. Brushes determine how the rendering is done. They can simply display a color or an image, tint content provided by node, or render using an arbitrary shader.

Nodes have foreground, background and composition brushes. These are accessed via ForegroundBrushProperty, BackgroundBrushProperty and CompositionBrushProperty

You can set the foreground brush:

textNode->setForegroundBrush(ColorBrush::create(domain, "color brush", ColorRGBA(0.5f, 1.0f, 0.5f, 1.0f)));

Foreground brush is used to render the content the node provides, for example an Image2D node provides an image. If node does not provide any foreground content, setting foreground brush has no effect.

You can set the background brush:

// Set color brush to draw the background of an empty brush.
empty->setBackgroundBrush(ColorBrush::create(domain, "color brush", ColorRGBA(0.8f, 1.0f, 0.2f, 1.0f)));

Background brush is used to render the content outside the node foreground area. If the node has no foreground or the foreground is translucent, background will fill the entire node area. If the node foreground fills the entire node area, no background will be rendered.

You can disable rendering by setting null brush:

// Disable rendering of foreground by setting a null brush.
image->setForegroundBrush(Brush::acquireNullBrush(*image->getResourceManager()));

Note that some nodes have default brushes, so removing the property would not be enough to disable rendering - the nodes would revert to default behavior.

Opacity

Node translucency is controlled by OpacityProperty. You can set the opacity of a node:

// Set image to blend halfway between the background and the image.
image->setOpacity(0.5f);

Opacity affects node background, foreground, and all node children.

Node foreground and background may be translucent even if opacity property is not set if the brushes or content are translucent.

If node has children, setting Node2D as translucent affects all children. To render the children correctly in regard to overlapping translucency, parent node may need to be composited. See section about composition for details.

Render transformation

You can modify RenderTransformationProperty to change where nodes are rendered in regard to their parent:

// Rotate node ~90 degrees counter-clockwise and translate it 50 units to the right.
node->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), -1.570796f, Vector2(50.0f, 0.0f)));

Render transformation is specified as SRT - Scale, Rotation and Translation.

Render transform is relative to top left of 2D nodes by default. You can change the origin point within the node by setting RenderTransformationOriginProperty:

// Set node to rotate around its center point as opposed to top left corner.
node->setRenderTransformationOrigin(Vector2(0.5f, 0.5f));

Render transformation origin can also be set outside the node.

// Set node to rotate around point that's on the node area bottom but three times its width to the left.
node->setRenderTransformationOrigin(Vector2(-3.0f, 1.0f));

The values set to render transform origin are relative to the size of the node. Value of 0.5 ; 0.5 will be the center of the node regardless of actual node size.

Render transformation happens after layout transformation has been already applied. Render transformation is not affected by layout constraints such as alignment and margins, and does not modify the size layout nodes take into account. For details about layout transformation, see the appropriate section.

Perspective transformation

You may apply perspective transformation in 3D space to bring limited 3D effects to 2D scene graph. Perspective transformation is an optional transformation applied as the last Node2D transformation. Perspective transformation applies after layout and render transformations have already been applied.

You can set the perspective transformation:

// Rotate 2D node slightly over the Y axis to give it perspective.
node->setPerspectiveTransformation(SRTValue3D(Vector3(1.0f, 1.0f, 1.0f), Vector3(0.0f, 0.2f, 0.0f), Vector3(0.0f, 0.0f, 0.0f)));

The projection for perspective transformation is applied in the space of current composition space. Perspective transformation is specified as 3D SRT - 3-component Scale, Rotation and Translation vectors.

Currently the perspective transform has the following rules:

  • Projection center is always at the center of the current composition target or screen.
  • Field of view is locket at 45 degrees. These restrictions are subject to change.

NodeVisual2D

All information related to foreground and background rendering in Node2D is stored in a separate object of type #NodeVisual2D. This object holds brush and geometry information required to render the node. To save memory, if node has nothing to render, no visual component is allocated.

Node2D will never release the visual component once it has been allocated once.

Composition

By default, nodes will be rendered into the rendering context of their parent. Usually, the top-level rendering context is the back buffer, provided by Screen node.

You can manually override this and render a node into a render target:

// Set a render target to render the empty node in.
emptyNode->setRenderTarget(renderTarget);

If a render target is specified, the node will take its size from the render target size. You can define fixed width and fixed height for a node that also has a render target set. The fixed size can be smaller then render target size. In this case, rendering will only happen on a part of the render target area. Specifying fixed size greater than render target size is undefined behavior. Nodes rendered into a render target will still draw the resulting composition to the rendering context of their parent.

Even if render target has not been set, nodes may be rendered using render targets to achieve correct result.

#Viewport2D will always render to a render target if its opacity is not 1.0 or if its transformation has non-translation components:

// Rotate viewport node 0.2 radians counter-clockwise.
// The viewport will need to be composited.
viewportNode->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.2f, Vector2(0.0f, 0.0f)));
// Returns true.
bool isInCompositionTarget = viewportNode->isSelfInCompositionTarget();

Viewport2D is a 'window' to a 3D scene. It must be aligned to the units in the parent render context. If this is not the case, it needs to be composited.

All nodes will render to render targets if they have children and their opacity is not one:

// Add an child to a parent node.
parentNode->addChild(childNode);
// Make the parent translucent.
// The parent will need a composition target to ensure correct rendering result.
parentNode->setOpacity(0.8f);
// Returns true.
bool isInCompositionTarget = parentNode->isSelfInCompositionTarget();

The parent has opacity set, so it will first need to do composition of all its children, and then render this composition using that opacity.

When you manually assign a render target you can set it to take its size from the size of the node. In this case, Kanzi resizes the composition target to the size that the node gets during layout:

// This example shows how to create a Texture and use it as a render target for a 2D node.
//
// Kanzi determines the size of the render target automatically from the size of the 2D node
// and renders the node:
// - To texture as specified with Node2D::setRenderTarget().
// - Only to texture as specified with Node2D::setOffscreenRendering().
//
// \see Node2D::RenderTargetProperty
// \see Node2D::OffscreenRenderingProperty
// \see Texture::CreateInfoNode2DRenderTarget
// \see Texture::create()
// Create a scene graph.
ScreenSharedPtr screen = Screen::create(domain, "screen");
screen->attach();
// Create a node.
// Set a size to the node to determine the size that Kanzi uses to set the size of the render target.
EmptyNode2DSharedPtr node = EmptyNode2D::create(domain, "node");
node->setWidth(static_cast<float>(width));
node->setHeight(static_cast<float>(height));
screen->addChild(node);
// Create a background brush for the node.
ColorBrushSharedPtr brush = ColorBrush::create(domain, "brush", ColorRGBA(0.4f, 0.4f, 0.9f, 1.0f));
node->setBackgroundBrush(brush);
// Create a render target texture for the node.
// To create a texture with the same size as the node to which you assign it, set width divisor and height divisor to 1.
textureCreateInfo.widthDivisor = 1;
textureCreateInfo.heightDivisor = 1;
TextureSharedPtr renderTarget = Texture::create(domain, textureCreateInfo, "texture");
node->setRenderTarget(renderTarget);
// Render only to render target texture.
node->setOffscreenRendering(true);
// Render the scene graph.
{
CompositionStack& compositionStack = renderer->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
screen->extract();
compositionStack.pushComposition(0, screen->getAllocatedSize());
screen->render(*renderer, compositionStack);
compositionStack.popComposition();
}
screen->detach();

Offscreen rendering

Nodes do not necessariyly have to draw their composition onto the render context of their parent. You can enable or disable offscreen rendering:

// Turn on offscreen rendering.
// The node will be rendered into its render target, but not blit onto the parent render context.
emptyNode->setOffscreenRendering(true);

If offscreen rendering is enabled, the node will not be drawn anywhere after rendering to its render target.

You can render the render target of the node using some other node:

// Set image to use the render target previously set on the empty node.
imageNode->setImage(emptyNode->getRenderTarget());

The render target behaves like a normal texture when used. Setting the render target to an Image2D will determine its size unless fixed size has been used.

Render target clearing rules

When a Node2D is rendered into a render target, it will clear the color and depth buffers of that render target. If the render target has a depth buffer, and the node is not a #Viewport2D that will clear it in a #Renderpass, the depth buffer will be cleared. If the node foreground does not fill complete composition area, or the combination of background and foreground is translucent, the color buffer will be cleared.

You can disable render target clearing:

// Disable clearing of render target even if it would otherwise be done.
emptyNode->setDisableRenderTargetClear(true);

Disabling clearing of render target will force the node to not clear even if it would otherwise decide to.

Cache render targets will be cleared if necessary even if clearing would be disabled.

Caching

You can cache Node2D rendering results to avoid rendering them every frame. There are three levels of caching. Caching the node content, caching node's children and caching the result combining both.

CacheSelfProperty controls caching the node content. You can enable or disable cache self:

// Enable caching of node content.
imageChildNode->setCacheSelf(true);

If CacheSelfProperty is enabled, node content will not change unless the property is disabled or the cache is invalidated. You can invalidate the cache:

// Force redraw of node content.
imageChildNode->resetCacheSelf();

After invalidating, the node content will be rendered once. After this, it is considered cached again.

CacheChildrenProperty controls caching of the children within the node area. You can enable or disable cache children:

// Enable caching of children and their locations within the node area.
parentNode->setCacheChildren(true);

If CacheChildrenProperty is enabled, the children or their locations will not change unless the property is disabled or the cache is invalidated. You can invalidate the cache:

// Force redraw of children.
imageChildNode->resetCacheChildren();

After invalidating, the children will be rendered once. After this, they are considered cached again.

CacheResultProperty controls caching of the complete node result. This means both the children and their locations and node content. You can enable or disable cache result:

// Enable caching of node area.
parentNode->setCacheResult(true);

If CacheResultProperty is enabled, nothing in the node area will not change unless the property is disabled or the cache is invalidated. You can invalidate the cache:

// Force redraw of node area.
parentNode->resetCacheResult();

After invalidating, the node area will be rendered once. After this, it is considered cached again.

You can enable or disable any combination of caches. Each level of cache is handled separately. The user is responsible for using this feature in a responsible manner. For example enabling self and children caches achieves the same visual effect as enabling result cache, but usually consumes more rendering time.

NodeCompositor2D

All information related to compositing is stored in a separate class of type #NodeCompositor2D. This object holds composition targets, caching information and a composition brush. Since compositing implies rendering, it is not possible to allocate a compositor without also allocating a #NodeVisual2D. To save memory, if composition is not needed, no compositor component is allocated.

Node2D will never release the compositor component once it has been allocated once. Composition targets within compositor may be released if not needed.

Basic Layout

2D nodes will try to determine their size automatically. 2D nodes with content will take the size of their content by default, e.g. Image2D will take the size of the image it displays. #EmptyNode2D and #Viewport2D have unbounded layout by default - they will take all available size. Available size for is calculated from the size of node's parent, or available screen area. You can use layouts such as #StackLayout2D and #GridLayout2D to arrange their children in a more complex manner.

You can set a fixed size to a 2D node, this will override the size it would otherwise assume:

// Set width to 160 units and height to 90 units.
node->setWidth(160.0f);
node->setHeight(90.0f);

You configure the node to determine its size automatically by removing fixed sizes:

// Set width and height to be determined automatically.
node->setAutoWidth();
node->setAutoHeight();

or:

// Set width and height to be determined automatically.
node->setAutoSize();

You can configure a node to take its width or height based on a specified fixed size and an aspect ratio:

// Sets node aspect ratio to ~16:9.
node->setAspectRatio(1.777778f);

If fixed width and aspect ratio are defined, height is width divided by aspect ratio. If fixed height and aspect ratio are defined, width is height multiplied by aspect ratio. If both fixed width and fixed height are defined, aspect ratio has no effect.

If neither width or height are defined, but aspect ratio is defined, the result depends on the node. Nodes that have unbounded layout, take the largest size they can with the given aspect ratio while still fitting within their allocated size. Aspect ratio has no effect with nodes with content that defines its size. This is analogous to having both fixed width and fixed height.

Nodes have an allocated area specified by the parent's area or a layout node. You can configure 2D node to align in its allocated area by setting horizontal and vertical alignment:

// Align node to right bottom corner of its parent.
node->setHorizontalAlignment(Node::HorizontalAlignmentRight);
node->setVerticalAlignment(Node::VerticalAlignmentBottom);

Horizontal alignment can be HorizontalAlignmentLeft, HorizontalAlignmentRight, HorizontalAlignmentCenter or HorizontalAlignmentStretch. Vertical alignment can be VerticalAlignmentTop, VerticalAlignmentBottom, VerticalAlignmentCenter or VerticalAlignmentStretch.

You can configure 2D node to fill its allocated area by setting alignment to stretch:

// Set node to fill the area of its parent.
node->setHorizontalAlignment(Node::HorizontalAlignmentStretch);
node->setVerticalAlignment(Node::VerticalAlignmentStretch);

You can offset 2D nodes from the edges of its parent:

// Offset node 20 units from left and top edges and 10 units from right and bottom edges of its parent.
node->setHorizontalMargin(Vector2(20.0f, 10.0f));
node->setVerticalMargin(Vector2(20.0f, 10.0f));

For horizontal margins, the order of values is left, then right. For vertical margins, the order of values is top, then bottom. If margins are not specified, the node will be aligned exactly at the edge of allocated area. If margins are specified, the node will be offset from the edge of allocated area by an amount equal to the margin.

Layout transformation

You can modify LayoutTransformationProperty to change the transformation of a node in regard to its parent:

// Rotate node ~45 degrees clockwise.
node->setLayoutTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.7853982f, Vector2(0.0f, 0.0f)));

Layout transform is specified as SRT - Scale, Rotation and Translation.

A node transformed with layout transformation gets its alignment and margin applied after the transformation. Render transformation is applied after layout transformation, alignment and margins.

For information about render transformation or perspective transformation, see the corresponding sections.

Content stretch

Node foreground content (e.g. image) has rules on how to stretch in relation to node area. The different content stretch modes are ContentStretchNone, ContentStretchFill, ContentStretchUniform and ContentStretchUniformToFill. You can set content stretch mode:

image->setContentStretch(Node::ContentStretchFill);

Having no value for content stretch is the same as having ContentStretchUniform. This means foreground content is stretched to fill node area while keeping its aspect ratio. If node aspect ratio is different from content aspect ratio, the remaining area is left for background rendering.

ContentStretchNone means the foreground area will be centered in node area and keep the exact size it would have, for example image size. If node is smaller than the foreground area, it will only display a part of the content. If node is larger than foreground area, the remaining area is left for background rendering.

ContentStretchFill means the foreground area will take the exact node area. This may alter the aspect ratio of content.

ContentStretchUniformToFill means the foreground area will be centered to node area and then uniformly scaled to fill it. If node aspect ratio is different from content aspect ratio, node will only display part of the content.

Layout in main loop

During the program main loop, layout is called for the root node. Before calling layout, the screen node allocated size will be set to current graphics output size. Layout pass only evaluates nodes marked as requiring layout. Render is called immediately after layout.

As render is called immediately after layout, user may do modification to the scene graph and see the changes before next call to user's update function. It may be useful to determine node calculated sizes or locations before waiting for the next frame. You may call layout manually:

// Add node to screen.
screen->addChild(node);
// To determine node actual size, must call layout.
// Before calling layout, must set allocated size of screen.
screen->setAllocatedSize(Vector2(1280.0f, 720.0f));
screen->layout();

After calling layout(), you can call getActualSize() to get the size determined by the node. Default allocated size is unbounded layout or infinity. When calling layout() manually, you must set allocated size for the node receiving the layout() call.

For details, see layout section under "Implementing custom node derived from Node2D".

Hit testing

You can hit test nodes in regard to their location on screen:

// Create an image nodes and add it to the parent node.
TextureSharedPtr texture = Texture::create(domain, Texture::CreateInfo2D(10, 10, GraphicsFormatR8G8B8_UNORM), "Example texture");
Image2DSharedPtr childNode = Image2D::create(domain, "child", texture);
parentNode->addChild(childNode);
// Align image to bottom right of parent.
parentNode->setWidth(400.0f);
parentNode->setHeight(300.0f);
childNode->setHorizontalAlignment(Node2D::HorizontalAlignmentRight);
childNode->setVerticalAlignment(Node2D::VerticalAlignmentBottom);
screen->layout();
// Parent is of size 400, 300, so 395, 295 will hit inside a child of size 10, 10.
NodeSharedPtr node = screen->hitTest(Vector2(395.0f, 295.0f));

Hit testing uses the 'world' or 'render' coordinates of the node. These coordinates are relative to the screen, not to the parent node or to the node that does the hit testing. Node visibility and all transformations are taken into account.

Hit testing transforms global coordinates into Node2D local coordinates to determine if the node is hit. You can determine world (screen) space coordinates in Node2D local coordinate space:

optional<Vector2> localCoords = childNode->globalToLocal(Vector2(50.0f, 40.0f));

The return enclosed in optional value, but is always valid if the node has a real is non-degenerate transformation.

You can test whether or not given coordinates would hit a node:

optional<Vector2> localCoords = childNode->containsGlobal(Vector2(50.0f, 40.0f));

Checking whether a global coordinate is within a node is equal to calling globalToLocal() and then testing the result with containsLocal().

Implementing custom node derived from Node2D

To do custom rendering and layout, a custom Node2D implementation must be implemented.

Defining the class

Custom Node2D implementations are defined by inheriting from Node2D base class.

To define a simple Node2D implementation see the following example:

class ExampleNode2D;
typedef shared_ptr<ExampleNode2D> ExampleNode2DSharedPtr;
class ExampleNode2D : public kanzi::Node2D
{
public:
static PropertyType<float> ExampleProperty;
float getExampleProperty() const
{
return getProperty(ExampleProperty);
}
void setExampleProperty(float value)
{
setProperty(ExampleProperty, value);
}
KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_PROPERTY_TYPE(ExampleProperty)
class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(ExampleMessageArguments, MessageArguments, "MyNamespace.ExampleNode2D.ExampleMessageArguments")
KZ_METACLASS_PROPERTY_TYPE(ExampleArgumentProperty)
};
static MessageType<ExampleMessageArguments> ExampleMessage;
static ExampleNode2DSharedPtr create(Domain* domain, string_view name);
protected:
explicit ExampleNode2D(Domain* domain, string_view name);
void initialize();
virtual Vector2 measureOverride(Vector2 availableSize) KZ_OVERRIDE;
virtual void updateRenderOverride() KZ_OVERRIDE;
void onExampleMessage(ExampleMessageArguments& arguments);
private:
ClassPropertyDefaultValue<float> m_classValueExampleProperty;
};

This example describes a very simple class inherited from Node2D.

The following sections go through parts of the node declaration one at a time and explain the segments.

Metaclass

Each class derived from Node2D must have a metaclass definition To declare the metaclass, inherit from Node2D base class and list the properties specific to the inherited node:

KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_PROPERTY_TYPE(ExampleProperty)

For details about metaclass, see the description in Node documentation.

Property types

Local property types are declared in metaclass to belong to the node. Additionally, property types must be declared within the node:

static PropertyType<float> ExampleProperty;

It is also often useful to declare setters and getters to wrap getProperty() and setProperty() for the custom property.

float getExampleProperty() const
{
return getProperty(ExampleProperty);
}
void setExampleProperty(float value)
{
setProperty(ExampleProperty, value);
}

After being declared in the class, the property must have a specific definition. The definition lists property metadata. The example property is defined as follows:

static PropertyType<float> ExampleProperty;

Note that the property has PropertyTypeChangeFlagFinalTransformation -flag set. This means that updateRender must be called for the node if it has been changed.

There are various property change flags that determine what has to be recalculated when the property is changed. PropertyTypeChangeFlagMeasure means the node has to be measured. This will cause measure and arrange to propagate from the node. measure() will be ran to the node and potentially all of its parents if measured size changed. Then, arrange() and updateRender() will be ran to node, all of the changed nodes and their descendants PropertyTypeChangeFlagArrange means the node has to be arranged. This will cause arrange to propagate from the node. arrange() and updateRender() will be ran to the node and all of its children. PropertyTypeChangeFlagFinalTransformation means that node transformation and transformations of its children have to be updated. updateRender() will be ran to the node and all its children.

Nodes may have class values for properties:

ClassPropertyDefaultValue<float> m_classValueExampleProperty;

Class values override the default value the node would have for a property otherwise, but the value applies only to objects of a certain class.

For more information about properties in nodes, refer to Node documentation.

Message types

To communicate with each other, nodes in Kanzi can send messages. Message types must be declared in nodes:

class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
KZ_MESSAGE_ARGUMENTS_METACLASS_BEGIN(ExampleMessageArguments, MessageArguments, "MyNamespace.ExampleNode2D.ExampleMessageArguments")
KZ_METACLASS_PROPERTY_TYPE(ExampleArgumentProperty)
static PropertyTypeEditorInfoSharedPtr makeEditorInfo();
};
static MessageType<ExampleMessageArguments> ExampleMessage;

Like the node itself, the message class must define a metaclass and properties.

Message type, metadata and related property metadata must be defined in addition to being declared in the node:

PropertyType<bool> ExampleNode2D::ExampleMessageArguments::ExampleArgumentProperty(kzMakeFixedString("MessageArgument.ExampleNode2D.Example"), false, 0, false,
(
metadata.displayName = "Example argument";
metadata.tooltip = "Example message argument property";
));
PropertyTypeEditorInfoSharedPtr ExampleNode2D::ExampleMessageArguments::makeEditorInfo()
{
[]() -> PropertyTypeEditorInfo::AttributeDictionary
{
PropertyTypeEditorInfo::AttributeDictionary dict;
dict.displayName = "Example message";
dict.tooltip = "Example definition of a message that can be listened.";
return dict;
}()
));
}
MessageType<ExampleNode2D::ExampleMessageArguments> ExampleNode2D::ExampleMessage(kzMakeFixedString("Message.ExampleNode2D.Example"), 0);

The argument definition is similar to property type definition. Also the message type and studio metadata need to be defined.

Node can subscribe to listen any messages. Typically on initialization.

For more information about messages, refer to Node documentation.

Initialize pattern

Constructing a node initializes node-specific values and passes to base class constructor.

ExampleNode2D::ExampleNode2D(Domain* domain, string_view name) :
Node2D(domain, name),
m_classValueExampleProperty(*this, ExampleProperty, 0.5f)
{
}

Class values are initialized in the constructor.

Further initialization is done in Node::initialize(), that is called from the create function:

ExampleNode2DSharedPtr ExampleNode2D::create(Domain* domain, string_view name)
{
ExampleNode2DSharedPtr exampleNode(new ExampleNode2D(domain, name));
exampleNode->initialize();
return exampleNode;
}

In this example, the node subscribes to listen a message defined earlier upon initialize:

void ExampleNode2D::initialize()
{
addMessageHandler(ExampleMessage, bind(&ExampleNode2D::onExampleMessage, this, placeholders::_1));
}
void ExampleNode2D::onExampleMessage(ExampleMessageArguments& arguments)
{
bool exampleArgument = arguments.getArgument(ExampleMessageArguments::ExampleArgumentProperty);
// Use argument value to set example property in node.
setExampleProperty(exampleArgument ? 1.0f : 0.0f);
}

For details of initialization, refer to Node documentation.

Attach and detach

When a node becomes a part of the scene graph, it is attached. When node no longer is a part of a scene graph, it is detached. Nodes may also be attached or detached if their parent is attached or detached - typically if their parent is added or removed from the scene graph.

Attaching connects and activates node features related to its location in the scene graph. This includes resource references, bindings, triggers, input manipulators, etc.

For details on attach and detach, refer to Node documentation.

Rendering

Custom node rendering is controlled by overriding rendering functions and setting the render type. During render process, nodes will first call their rendering functions, and then rendering will descend to the children.

Rendering functions

To override foreground rendering, implement renderForegroundOverride(). Default implementation of renderForegroundOverride() is empty, since all nodes decide on their own rendering.

You can override all rendering of node itself, meaning both foreground and background, by implementing renderSelfOverride(). Default implementation of renderSelfOverride() applies the composition stack, and then defers to background and foreground rendering. When implementing this function, remember to ensure that the viewport settings are correct before issuing draw calls. Applying the composition stack

To use normal background rendering within overridden rendering, call renderBackground(). renderBackground() checks if background brush exists, and then renders the background quad. In the case of opaque foreground, background rendering will render a 'frame' around the node content area if possible.

For most nodes, implementing renderSelfOverride() is enough.

Render type

Node2D rendering is controlled by RenderType. It should be set upon constructor or node initialization to reflect on node rendering behavior. RenderType acts as a hint to the rendering system, regarding how to set viewport settings and how to handle background rendering.

RenderTypeNone is used for nodes that do not have a foreground and will not render it.

RenderTypeTexture is used for nodes that render their foreground as a rectangular quad - for example #Image2D.

RenderTypeManual is used for nodes that handle their own foreground rendering. It implies the system having to set up viewport coordinates for the area of the node, this will push a local viewport area onto the composition stack. Nodes using RenderTypeManual should implement renderSelfOverride.

RenderTypeManualClipped is using nodes that handle their own foreground rendering, but do not need a local viewport area. This implies nodes using RenderTypeManualClipped either clip their own content, or that the user does not care about clipping. Nodes using RenderTypeManualClipped should implement at least renderForegroundOverride, possibly renderSelfOverride.

Layout

Custom nodes also follow the layout directives described in the earlier section. Layout can be partially overridden by implementing layout functions.

Node desired size is determined in measure(). Measurement pass descends recursively downwards until nodes that are flagged as needing measure are found. For every node the size of which was changed, measure ascends upwards to the root and flags node as requiring arrange. To override the size that would otherwise be determined for the node, implement measureOverride():

Vector2 ExampleNode2D::measureOverride(Vector2 /*availableSize*/)
{
return Vector2(128.0f, 128.0f);
}

Content desired size for node is determined by the size returned from measureOverride(). Desired size for node is affected by the content desired size returned and node properties.

Node actual size and transformation is determined in arrange(). Arrange pass descends recursively downwards to nodes that are flagged as needing arrange, and then arranges them and all their children. Arrange process reads available size for node, then determines transformation and actual size based on node properties.

Nodes performing layout on theit children, for example #StackLayout2D, must implement arrangeOverride(). During parent arrange pass, children have already been measured. Arranging children works by iterating over child nodes and setting their allocated sizes and arrange transformations. For non-layout nodes, (default) arrangeOverride() sets child node allocated size as the node actual size, and resets child arrange transformation.

Node final transformation, brushes and composition settings are determined in updateRender(). updateRender() is called after arrange for all nodes that were marked as requiring transformation updated. Nodes may implement updateRenderOverride() to do custom clipping or modify brush or composition settings:

void ExampleNode2D::updateRenderOverride()
{
// Check if we have a color brush as background brush.
ColorBrushSharedPtr brush = dynamic_pointer_cast<ColorBrush>(getBackgroundBrush());
if (brush)
{
// Set blue component of color depending on our example property.
ColorRGBA color = brush->getColor();
color.setBlue(getExampleProperty());
brush->setColor(color);
}
}

Member Typedef Documentation

Container type for children.

typedef ChildContainer::const_iterator kanzi::Node2D::ChildConstIterator

Iterator type for children.

typedef ChildContainer::const_reverse_iterator kanzi::Node2D::ChildConstReverseIterator

Reverse iterator type for children.

typedef NodeSharedPtr(* kanzi::Node2D::HitTestVisitor) (Node2D &node, Vector2 nodePoint, void *userData)

Hit test visitor function.

Member Enumeration Documentation

Enumerator
PixelFormatRgb 

Managed render targets use RGB format.

PixelFormatRgba 

Managed render targets use RGBA format.

Hint for foreground handling of nodes.

Enumerator
ForegroundHintNone 

No hint given, assumed the background of a node can be rendered after content.

ForegroundHintTranslucent 

Some elements rendered within the node are translucent over the background.

ForegroundHintOpaque 

Node content is assumed to be fully opaque thus, that background does not need to be rendered.

Node2D render type - affects elementary decisions about node rendering.

Enumerator
RenderTypeNone 

Will not render itself except for its children.

RenderTypeTexture 

Node will render itself as textured quad.

RenderTypeManual 

Node handles its own rendering.

RenderTypeManualClipped 

Node handles its own rendering, but also clips its own content.

This means the node using this will not need additional composition area definitions, and can rendered directly.

Different Node2D flags for bit set.

Enumerator
AllowClear 

Is clearing allowed? This flag is turned on by default, but can be disabled by node properties.

2D nodes only clear color buffers, even if other buffers are created.

AllowRenderChildren 

Are children rendered for this node or are they handled in a special manner?

AllowRenderSelf 

Is the node allowed to render itself?

ForegroundIsTranslucent 

Does layout detected foreground translucency?

ForegroundTranslucencyRequested 

Has an extra request been filed (by implementations) for foreground translucency?.

RequiresBackgroundQuad 

Is background quad required.

RequiresExtract 

Does the node need extract called?

ChildrenRequireExtract 

Does the node have children that need extract?

Node2DFlagsBitCount 

Number of options.

Constructor & Destructor Documentation

virtual kanzi::Node2D::~Node2D ( )
virtual
kanzi::Node2D::Node2D ( Domain domain,
string_view  name 
)
explicitprotected

Constructor.

Parameters
domainDomain to use.
nameNode name.

Member Function Documentation

static float kanzi::Node2D::layoutUp ( )
inlinestatic
static bool kanzi::Node2D::isValidLayoutSize ( Vector2  size)
inlinestatic

Indicates whether a size is valid layout size.

Size is valid if all its elements are valid layout values (see Node::isValidLayoutValue()).

Parameters
sizeSize to test if it is unbound layout size.
Returns
true if the size if valid layout size, false otherwise.
static Vector2 kanzi::Node2D::unboundedLayoutSize ( )
inlinestatic

Returns an unbounded layout size.

Returns
Unbounded layout size.
static bool kanzi::Node2D::isUnboundedLayoutSize ( Vector2  layoutSize)
inlinestatic

Indicates whether a layout size is an unbound layout size.

Size is layout unbound size if any of its elements is unbounded layout value.

Parameters
layoutSizeLayout size to test if it is unbound layout size.
Returns
true if the layoutSize is unbound layout size, false otherwise.
static Vector2 kanzi::Node2D::replaceUnboundedLayoutSize ( Vector2  layoutSize,
Vector2  resetSize 
)
inlinestatic

Replaces any element of a layout size with appropriate element of the reset size if it is unbounded and returns the size.

Parameters
layoutSizeLayout size to test if any of its elements is unbounded layout value.
resetSizeThe size whose values are used as a replacement for specified layout size's unbounded value elements.
Returns
layoutSize with its unbounded value elements replaced with the elements of resetSize.
static Vector2 kanzi::Node2D::replaceUnboundedLayoutSizeWithZero ( Vector2  layoutSize)
inlinestatic

Replaces any element of a layout size with zero if it is unbounded and returns the size.

Parameters
layoutSizeLayout size to test if any of its elements is unbounded layout value.
Returns
layoutSize with its unbounded value elements replaced with zero.
float kanzi::Node2D::getAspectRatio ( ) const
inline

Gets the value of AspectRatioProperty.

See also
setAspectRatio()
void kanzi::Node2D::setAspectRatio ( float  value)
inline

Sets the value of AspectRatioProperty.

See also
getAspectRatio()
bool kanzi::Node2D::isForceComposition ( ) const
inline

Gets the value of ForceCompositionProperty.

See also
setForceComposition()
void kanzi::Node2D::setForceComposition ( bool  value)
inline

Sets the value of ForceCompositionProperty.

See also
isForceComposition()
Node2D::ForegroundHint kanzi::Node2D::getForegroundHint ( ) const
inline

Gets the value of ForegroundHintProperty.

See also
setForegroundHint()
void kanzi::Node2D::setForegroundHint ( Node2D::ForegroundHint  value)
inline

Sets the value of ForegroundHintProperty.

See also
getForegroundHint()
bool kanzi::Node2D::isCacheChildren ( ) const
inline

Gets the value of CacheChildrenProperty.

See also
setCacheChildren()
void kanzi::Node2D::setCacheChildren ( bool  value)
inline

Sets the value of CacheChildrenProperty.

See also
isCacheChildren()
bool kanzi::Node2D::isCacheResult ( ) const
inline

Gets the value of CacheResultProperty.

See also
setCacheResult()
void kanzi::Node2D::setCacheResult ( bool  value)
inline

Sets the value of CacheResultProperty.

See also
isCacheResult()
bool kanzi::Node2D::isCacheSelf ( ) const
inline

Gets the value of CacheSelfProperty.

See also
setCacheSelf()
void kanzi::Node2D::setCacheSelf ( bool  value)
inline

Sets the value of CacheSelfProperty.

See also
isCacheSelf()
bool kanzi::Node2D::isOffscreenRendering ( ) const
inline
void kanzi::Node2D::setOffscreenRendering ( bool  value)
inline
bool kanzi::Node2D::isDisableRenderTargetClear ( ) const
inline
void kanzi::Node2D::setDisableRenderTargetClear ( bool  value)
inline
Node2D::PixelFormat kanzi::Node2D::getPixelFormat ( ) const
inline

Gets the value of PixelFormatProperty.

See also
setPixelFormat()
void kanzi::Node2D::setPixelFormat ( Node2D::PixelFormat  value)
inline

Sets the value of PixelFormatProperty.

See also
getPixelFormat()
bool kanzi::Node2D::isRenderSelf ( ) const
inline

Gets the value of RenderSelfProperty.

See also
setRenderSelf()
void kanzi::Node2D::setRenderSelf ( bool  value)
inline

Sets the value of RenderSelfProperty.

See also
isRenderSelf()
float kanzi::Node2D::getRenderTargetMinimumHeight ( ) const
inline
void kanzi::Node2D::setRenderTargetMinimumHeight ( float  value)
inline
float kanzi::Node2D::getRenderTargetMinimumWidth ( ) const
inline
void kanzi::Node2D::setRenderTargetMinimumWidth ( float  value)
inline
float kanzi::Node2D::getRenderTargetReallocationLimit ( ) const
inline
void kanzi::Node2D::setRenderTargetReallocationLimit ( float  value)
inline
Vector2 kanzi::Node2D::getRenderTransformationOrigin ( ) const
inline
void kanzi::Node2D::setRenderTransformationOrigin ( Vector2  value)
inline
bool kanzi::Node2D::isSnapToPixel ( ) const
inline

Gets the value of SnapToPixelProperty.

See also
setSnapToPixel()
void kanzi::Node2D::setSnapToPixel ( bool  value)
inline

Sets the value of SnapToPixelProperty.

See also
isSnapToPixel()
static PropertyTypeEditorInfoSharedPtr kanzi::Node2D::makeEditorInfo ( )
static
ChildConstIterator kanzi::Node2D::beginChildren ( ) const
ChildConstIterator kanzi::Node2D::endChildren ( ) const
ChildConstReverseIterator kanzi::Node2D::rbeginChildren ( ) const
ChildConstReverseIterator kanzi::Node2D::rendChildren ( ) const
void kanzi::Node2D::addChild ( Node2DSharedPtr  child)

Adds a child node.

Adding a 3D node node as a child of a 2D node is only allowed when adding a scene to a viewport. Screens can have only one child which is a 2D node.

void kanzi::Node2D::insertChild ( size_t  index,
Node2DSharedPtr  child 
)

Adds a child node for object node to given index.

Adding a 3D node node as a child of a 2D node is only allowed when adding a scene to a viewport. Screens can have only one child which is a 2D node.

void kanzi::Node2D::removeChild ( const Node child)

Removes child node.

void kanzi::Node2D::removeChild ( size_t  index)

Removes child node at specified index.

void kanzi::Node2D::removeAllChildren ( )

Removes all child nodes.

Node2DSharedPtr kanzi::Node2D::getChild ( size_t  index) const

Returns a child from given index from object node.

size_t kanzi::Node2D::getChildIndex ( const Node child) const

Returns the index of a child in an object node.

bool kanzi::Node2D::hasChild ( const Node child) const

Returns whether or not the child exists.

size_t kanzi::Node2D::getChildCount ( ) const

Gets the number of children of the node.

void kanzi::Node2D::moveToBack ( )

Repositions the node to the beginning of its parent's children, so that it is drawn first.

void kanzi::Node2D::moveToFront ( )

Repositions the node to the end of its parent's children, so that it is drawn last.

RenderType kanzi::Node2D::getRenderType ( ) const
inline

Get render type.

Returns
Render type enumeration.
BrushSharedPtr kanzi::Node2D::getBackgroundBrush ( ) const
inline

Gets value of BackgroundBrushProperty.

void kanzi::Node2D::setBackgroundBrush ( BrushSharedPtr  value)
inline

Sets value of BackgroundBrushProperty.

BrushSharedPtr kanzi::Node2D::getCompositionBrush ( ) const
inline

Gets value of CompositionBrushProperty.

void kanzi::Node2D::setCompositionBrush ( BrushSharedPtr  value)
inline

Sets value of CompositionBrushProperty.

BrushSharedPtr kanzi::Node2D::getForegroundBrush ( ) const
inline

Gets value of ForegroundBrushProperty.

void kanzi::Node2D::setForegroundBrush ( BrushSharedPtr  value)
inline

Sets value of ForegroundBrushProperty.

BrushRenderer* kanzi::Node2D::getBackgroundBrushRenderer ( ) const
inline

Get background brush renderer.

Returns
Pointer to background brush renderer.
BrushRenderer* kanzi::Node2D::getForegroundBrushRenderer ( ) const
inline

Get foreground brush renderer.

Returns
Pointer to foreground brush renderer.
BrushRenderer* kanzi::Node2D::getCacheChildrenBrushRenderer ( ) const
inline

Access cache children brush renderer.

Returns
Pointer to brush renderer.
BrushRenderer* kanzi::Node2D::getCacheSelfBrushRenderer ( ) const
inline

Access cache self brush renderer.

Returns
Pointer to brush renderer.
BrushRenderer* kanzi::Node2D::getCompositionBrushRenderer ( ) const
inline

Access cache result brush renderer.

Returns
Pointer to brush renderer.
SRTValue2D kanzi::Node2D::getRenderTransformation ( ) const
inline
void kanzi::Node2D::setRenderTransformation ( SRTValue2D  value)
inline
SRTValue3D kanzi::Node2D::getPerspectiveTransformation ( ) const
inline
void kanzi::Node2D::setPerspectiveTransformation ( SRTValue3D  value)
inline
void kanzi::Node2D::render ( Renderer3D renderer,
CompositionStack compositionStack 
)

Render individual 2D node.

Parameters
rendererRenderer to use.
compositionStackRender context stack to use.
NodeVisual2D* kanzi::Node2D::getVisual ( ) const
inline

Access visual component.

Returns
Pointer to visual component or NULL if it doesn't exist.
TextureSharedPtr kanzi::Node2D::getRenderTarget ( ) const
inline

Gets value of RenderTargetProperty.

void kanzi::Node2D::setRenderTarget ( TextureSharedPtr  texture)
inline

Sets value of RenderTargetProperty.

TextureSharedPtr kanzi::Node2D::getFinalCompositionTarget ( ) const
inline

Returns composition target combining all Node2D content.

This is either user-set composition target or automatically created one.

May return empty shared pointer if no composition target has been created or set.

bool kanzi::Node2D::hasCacheChildren ( ) const
inline

Tell if node should cache its children.

Should only be used from outside the node.

bool kanzi::Node2D::hasCacheChildrenCompositionTarget ( ) const
inline

Tell if node has cache children composition target.

Should only be used from outside the node.

bool kanzi::Node2D::isCacheChildrenValid ( ) const
inline

Tell if children cache is valid.

void kanzi::Node2D::resetCacheChildren ( )
inline

Reset cached content for children.

Does not change the caching property - if caching is on, the cache will be recreated on next render.

bool kanzi::Node2D::hasCacheResult ( ) const
inline

Tell if node should cache its result.

This means the combination of node itself and its children.

Should only be used from outside the node.

bool kanzi::Node2D::hasFinalCompositionTarget ( ) const
inline

Tell if node has final composition target.

Should only be used from outside the node.

bool kanzi::Node2D::isCacheResultValid ( ) const
inline

Tell if children cache is valid.

void kanzi::Node2D::resetCacheResult ( )
inline

Reset cached content for complete node content including itself and its children.

Does not change the caching property - if caching is on, the cache will be recreated on next render.

bool kanzi::Node2D::hasCacheSelf ( ) const
inline

Tell if node should cache itself.

Should only be used from outside the node.

bool kanzi::Node2D::hasCacheSelfCompositionTarget ( ) const
inline

Tell if node has cache children composition target.

Should only be used from outside the node.

bool kanzi::Node2D::isCacheSelfValid ( ) const
inline

Tell if children cache is valid.

void kanzi::Node2D::resetCacheSelf ( )
inline

Reset cached content for node itself.

Does not change the caching property - if caching is on, the cache will be recreated on next render.

CompositionManager* kanzi::Node2D::getCompositionManager ( ) const
inline

Access composition manager.

NodeCompositor2D* kanzi::Node2D::getCompositor ( ) const
inline

Access compositor component.

Returns
Pointer to compositor component or NULL if it doesn't exist.
void kanzi::Node2D::setAutoWidth ( )

Sets node to automatically determine width.

void kanzi::Node2D::setAutoHeight ( )

Sets node to automatically determine height.

void kanzi::Node2D::setAutoSize ( )

Sets node to automatically determine both width and height.

void kanzi::Node2D::setSize ( float  width,
float  height 
)

Sets size properties of the node.

Parameters
widthThe value of the WidthProperty.
heightThe value of the HeightProperty.
void kanzi::Node2D::setLayoutSize ( float  width,
float  height 
)
inline

Sets size properties of the node.

Deprecated:
This function is deprecated! Use setSize instead.
See also
setSize
SRTValue2D kanzi::Node2D::getLayoutTransformation ( ) const
inline
void kanzi::Node2D::setLayoutTransformation ( SRTValue2D  value)
inline
Vector2 kanzi::Node2D::getDesiredSize ( ) const
inline

Get desired size.

Returns
Size vector.
void kanzi::Node2D::setDesiredSize ( Vector2  size)
inline

Set desired size.

Parameters
sizeNew size vector.
Vector2 kanzi::Node2D::getAllocatedSize ( ) const
inline

Get allocated size.

Returns
Size vector.
void kanzi::Node2D::setAllocatedSize ( Vector2  allocatedSize)
inline

Set allocated size.

If allocated size differs from existing, will invalidate arrange as a side effect.

Parameters
sizeNew size vector.
Vector2 kanzi::Node2D::getActualSize ( ) const
inline

Get actual size.

Returns
Size vector.
void kanzi::Node2D::setActualSize ( Vector2  actualSize)
inline

Set actual size.

Parameters
sizeNew size vector.
void kanzi::Node2D::setActualSize ( float  sizeX,
float  sizeY 
)
inline

Set actual size.

Parameters
sizeXNew size X component.
sizeYNew size Y component.
Matrix3x3 kanzi::Node2D::getArrangeTransform ( ) const
inline

Get arrange transform.

Returns
Transformation matrix.
void kanzi::Node2D::setArrangeTransform ( Matrix3x3  transform)
inline

Set arrange transform.

If Layout transform differs existing, will invalidate arrange as a side effect.

Parameters
transformNew transformation matrix.
void kanzi::Node2D::layout ( optional< Matrix3x3 rootTransform)

Does layout pass starting from this node and iterating recursively all of its children.

Measure pass only descends up to nodes marked for requiring measure and then propagates upwards for all nodes that were changed. After measure, all nodes marked for requiring arrange and all their children are arranged.

Node actual size is not known before layout. User may call layout manually to determine node actual sizes. Before calling layout, the node must have allocated size set to limit node area to anything less than infinity. Normal layout process sets allocated size to current composition size.

Parameters
rootTransformTransform applied to root node for arrange pass if set. Can be used to offset complete scene graph, but should usually be empty.
void kanzi::Node2D::layout ( )
inline

Does layout pass with no root transformation (identity).

Otherwise same as layout() with optional Matrix3x3.

bool kanzi::Node2D::measure ( const Vector2 availableSize,
bool  handleStretch 
)

Measure one node.

Parameters
availableSizeAvailable size passed from parent, may be NULL.
handleStretchShould the node handle stretching of node to fill available space?
Returns
True if measure should be propagated, false if not.
virtual bool kanzi::Node2D::measureRecursive ( )
virtual

Perform measure recursively.

TODO explain why this is virtual

Reimplemented in kanzi::Viewport2D.

void kanzi::Node2D::arrange ( )

Arrange one Node2D.

void kanzi::Node2D::extract ( )

Extract one Node2D.

Matrix3x3 kanzi::Node2D::getWorldTransform ( ) const
inline

Get world transform.

Returns
Transformation matrix.
bool kanzi::Node2D::containsLocal ( Vector2  point) const

Tell if a node area contains a point (defined in node's own space).

Returns
True if yes, false if no.
optional<Vector2> kanzi::Node2D::containsGlobal ( Vector2  point) const

Tell if a node area contains a point (defined in screen space).

If true, the node-space coordinates have been written into outgoing point.

optional<Vector2> kanzi::Node2D::globalToLocal ( Vector2  point) const
NodeSharedPtr kanzi::Node2D::hitTest ( Vector2  point)

Performs a hit test to a 2D node and all its child nodes.

Returns the topmost 2D node under given point.

Parameters
pointPoint in world coordinates.
Returns
Node hit or an empty shared pointer.
NodeSharedPtr kanzi::Node2D::hitTest ( Vector2  point,
const Metaclass type 
)

Performs a hit test to a 2D node and all its child nodes.

This is a wrapper function that allows to filter only selected types of nodes for hit testing.

Parameters
pointPoint in world coordinates.
typeMetaclass type to limit hit testing to.
Returns
Node hit or an empty shared pointer.
NodeSharedPtr kanzi::Node2D::hitTestIterate ( Vector2  point,
HitTestVisitor  visitor,
void *  userData 
)

Recursively hit test nodes from this node downwards and call visitor function on nodes hit.

Used for specific implementations of hit testing.

Parameters
pointPoint in world coordinates.
visitorVisitor function to call on nodes.
userDataUser data passed to visitor function.
Returns
Node hit or an empty shared pointer.
virtual tuple<NodeSharedPtr, KzcRay, float> kanzi::Node2D::hitTestContent ( Vector2  point)
virtual

Default implementation of Node2D content hit test.

Just returns the node itself.

Parameters
pointPoint in node space.
Returns
Tuple of found node, ray hitting that node and distance along the ray.

Reimplemented in kanzi::Viewport2D.

template<typename T >
shared_ptr<T> kanzi::Node2D::hitTest ( Vector2  point)
inline

Wrapper for hitTest(Vector2), casts the return value.

Parameters
pointPoint in world coordinates.
Returns
Typed node hit or an empty shared pointer.
template<typename T >
shared_ptr<T> kanzi::Node2D::hitTest ( Vector2  point,
const Metaclass type 
)
inline

Wrapper for hitTest(Vector2, const Metaclass), casts the return value.

Parameters
pointPoint in world coordinates.
typeMetaclass type to limit hit testing to.
Returns
Typed node hit or an empty shared pointer.
virtual NodeSharedPtr kanzi::Node2D::findAbstractChildOverride ( string_view  name)
virtual

Node::findAbstractChildOverride() implementation.

TODO: to be moved to protected

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

virtual VisitorResult kanzi::Node2D::visitAbstractChildOverride ( const Visitor visitor,
VisitorOrder  order 
)
virtual

Node::visitAabstractChild implementation.

TODO: to be moved to protected

Implements kanzi::Node.

Reimplemented in kanzi::Viewport2D.

virtual bool kanzi::Node2D::addAbstractChildOverride ( NodeSharedPtr  child)
virtual

Node::addAbstractChildOverride() implementation.

Implements kanzi::Node.

virtual size_t kanzi::Node2D::getAbstractChildCountOverride ( )
virtual
virtual NodeSharedPtr kanzi::Node2D::getAbstractChildOverride ( size_t  index)
virtual

Node::getAbstractChildOverride() implementation.

Implements kanzi::Node.

virtual bool kanzi::Node2D::removeAbstractChildOverride ( Node child)
virtual

Node::removeAbstractChildOverride() implementation.

Implements kanzi::Node.

bool kanzi::Node2D::compositionRequiresAlpha ( ) const
inline

Tell if composition requires alpha.

Returns
True if yes, false if no.
void kanzi::Node2D::setCompositionRequiresAlpha ( bool  enabled)
inline

Turn composition alpha requirement on or off.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::compositionRequiresDepth ( ) const
inline

Tell if composition requires depth.

Returns
True if yes, false if no.
void kanzi::Node2D::setCompositionRequiresDepth ( bool  enabled)
inline

Turn composition depth requirement on or off.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::compositionRequiresStencil ( ) const
inline

Tell if composition requires stencil.

Returns
True if yes.
void kanzi::Node2D::setCompositionRequiresStencil ( bool  enabled)
inline

Turn composition stencil requirement on or off.

Parameters
enabledTrue to turn on, false to turn off.
QuadDescription kanzi::Node2D::getBackgroundQuad ( ) const
inline

Gets the background quad description.

This function returns a copy of the background quad struct. Should be only used for tests.

ClippingArea kanzi::Node2D::getClippingArea ( ) const
inline

Get clipping area.

This function returns a copy of the clipping struct. Should be only used for tests.

float kanzi::Node2D::getLayoutOpacity ( ) const
inline

Get opacity after propagation from layouting hierarchy.

Returns
Current layouted opacity.
Matrix3x3 kanzi::Node2D::getRenderQuadTransform ( ) const
inline

Gets transformation used to render the 2D node.

Returns
Transform reference.
bool kanzi::Node2D::hasCenterClipArea ( ) const
inline

Tell if Node2D has the center clip area (the area of itself).

Returns
True if yes, false if no.
bool kanzi::Node2D::hasOutsideClipArea ( ) const
inline

Tell if Node2D has outside clipping area.

This means any area outside clipping area.

Returns
True if yes, false if no.
bool kanzi::Node2D::hasTranslucentForeground ( ) const
inline

Tell if Node2D foreground has translucency.

Returns
True if yes, false if no.
void kanzi::Node2D::setForegroundIsTranslucent ( bool  enabled)
inline

Set foreground translucency status.

This is calculated from layout time to combine factors deciding translucency.

Parameters
enabledTrue to enable, false to disable.
void kanzi::Node2D::setFinalCompositionRequested ( bool  enabled)
inline

Turn composition request on or off.

This is a composition request from code, not by setting a property.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::isCompositionClearColorRequired ( ) const
inline

Indicates whether composition target requires color clear before rendering.

Composition clear is requested if, for some reason, node does not fill complete foreground area. This may be due to the foreground being smaller than node area or due to the foreground not being present.

Composition clear being requested does not tell whether or not it is allowed. There may be external reasons such as background brush covering the complete node area or clearing being disabled that prevent it.

bool kanzi::Node2D::isClearColorAllowed ( ) const
inline

Indicates whether this Node2D is allowed and should clear the color buffer of its own composition target.

By default, clearing is allowed but can be explicitly denied by user using properties.

This function does not access the property, but rather a flag determined during layout.

void kanzi::Node2D::setClearColorAllowed ( bool  enabled)
inline

Set clear color allowed.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::isRenderChildrenAllowed ( ) const
inline

Tell if rendering children is allowed.

Returns
True if yes, false if no.
bool kanzi::Node2D::isRenderSelfAllowed ( ) const
inline

Tell if render self is allowed.

Returns
True if yes, false if no.
bool kanzi::Node2D::isVisibleForHitTesting ( ) const
inline

Tell if Node2D is visible for hit testing.

This is different from node being merely visible, it must also be not rendered offscreen.

Returns
True if yes, false if no.
bool kanzi::Node2D::requiresBackgroundBrushRendering ( ) const
inline

Tell if background brush rendering is required.

Returns
True if yes, false if no.
bool kanzi::Node2D::requiresForegroundBrushRendering ( ) const
inline

Tell if foreground brush rendering is required.

Returns
True if yes, false if no.
bool kanzi::Node2D::hasChildrenRequireExtract ( ) const
inline

Tell if children require extract flag is on.

Returns
True if yes, false if no.
void kanzi::Node2D::setChildrenRequireExtract ( bool  enabled)
inline

Set children require extract flag.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::requiresExtract ( ) const
inline

Tell if node requires extraction.

Returns
True if yes, false if no.
void kanzi::Node2D::setRequiresExtract ( bool  enabled)
inline

Turn extract requirement on or off.

Parameters
enabledTrue to turn on, false to turn off.
bool kanzi::Node2D::isSelfInCompositionTarget ( ) const
inline

Tell if node itself is going to get rendered into a composition target.

This is analogous to the final node result or the node itself being rendered into a composition target.

Vector2 kanzi::Node2D::getContentDesiredSize ( ) const
inline

Get size desired by content.

TODO: ugly

Returns
Size vector.
Vector2 kanzi::Node2D::getSecondPassDesiredSize ( ) const
inline

Get second pass desired size.

TODO: ugly

Returns
Size vector.
Vector2 kanzi::Node2D::getUserDesiredSize ( ) const
inline

Get size desired by user.

TODO: ugly

Returns
Size vector.
Matrix3x3 kanzi::Node2D::getPartialArrangeTransform ( ) const
inline

Get partial arrange transform.

TODO: ugly

Returns
Propagate transform.
void kanzi::Node2D::initialize ( )
protected
NodeVisual2D& kanzi::Node2D::acquireVisual ( )
protected

Initializes and returns visual structure.

TODO: rename to NodeVisual2D Allocates memory for rendering-related information. By default this information is unallocated.

virtual void kanzi::Node2D::renderOverride ( Renderer3D renderer,
CompositionStack compositionStack 
)
protectedvirtual

Node-specific top-level render call.

Allows for overriding the complete Node2D rendering process. Should normally not be overridden. Even if overridden, inherited implementations should usually call base implementation.

Parameters
rendererRenderer.
compositionStackRender context stack.
void kanzi::Node2D::renderRecursive ( Renderer3D renderer,
CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protected

Render a Node2D and then recursively all its children.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
virtual void kanzi::Node2D::renderSelfOverride ( Renderer3D renderer,
CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protectedvirtual

Node-specific rendering.

Default implementation renders background normally and passes to foreground render. Inherit to render more complex forms.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
quadQuad to use for filling node area.

Reimplemented in kanzi::Viewport2D, kanzi::ProgressiveRenderingViewport2D, kanzi::TextBlock2D, and kanzi::Portal.

void kanzi::Node2D::renderChildren ( Renderer3D renderer,
CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protected

Render all children of a Node2D.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
void kanzi::Node2D::renderBackground ( Renderer3D renderer,
const CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protected

Render background quad of a Node2D.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
void kanzi::Node2D::renderForeground ( Renderer3D renderer,
CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protected

Render foreground of a Node2D.

Calls renderForegroundOverride().

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
virtual void kanzi::Node2D::renderForegroundOverride ( Renderer3D renderer,
CompositionStack compositionStack,
const Matrix3x3 baseTransform 
)
protectedvirtual

Node-specific foreground render.

Default implementation does nothing.

Parameters
rendererRenderer.
compositionStackRender context stack.
baseTransformTransform applied to node itself in parent space.
bool kanzi::Node2D::pushLocalViewportArea ( CompositionStack compositionStack)
protected

Push local viewport and scissor area into composition stack if it's required.

Nodes with render mode #RenderModeManual will rely on viewport and scissoring settings to clip their output. This needs an additional composition area pushed to the composition stack.

Parameters
compositionStackComposition stack.
Returns
True if a new area was pushed into composition stack and needs to be popped after rendering.
NodeCompositor2D& kanzi::Node2D::acquireCompositor ( )
protected

Initializes and returns composition structure.

TODO: rename to NodeCompositor2D Allocates memory for all composition-related information. By default this information is unallocated.

void kanzi::Node2D::clearCompositionTarget ( Renderer3D renderer,
CompositionStack compositionStack,
bool  clearColor 
)
protected

Clear node render target.

Parameters
rendererRenderer to use.
renderTargetRender target to clear.
limitsRender target size.
clearColorClear color buffer.
virtual void kanzi::Node2D::arrangeRecursive ( const Matrix3x3 worldTransform,
const Matrix3x3 parentTransform,
bool  arrangeNeeded,
bool  transformChanged 
)
protectedvirtual

Perform arrange recursively.

Reimplemented in kanzi::Viewport2D.

optional<float> kanzi::Node2D::getUserAspectRatio ( ) const
protected

Get aspect ratio property assigned to the node.

Aspect ratio of 0 or smaller equals no aspect ratio set.

Returns
optional aspect ratio.
optional<float> kanzi::Node2D::getUserHeight ( ) const
protected

Get layout height property assigned to the node.

Having an offscreen render target overrides the node's default size.

Sizes smaller than 0 are clamped to 0.

Returns
Optional height.
optional<float> kanzi::Node2D::getUserWidth ( ) const
protected

Get layout width property assigned to the node.

Having an offscreen render target overrides the node's default size.

Sizes smaller than 0 are clamped to 0.

Returns
Optional width.
Vector2 kanzi::Node2D::getDesiredSizeAxisAlignedBoundingBoxMinimum ( ) const
inlineprotected

Get desired size axis aligned bounding box minimum.

Returns
Desired size minimum.
void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMinimum ( Vector2  size)
inlineprotected

Set desired size axis aligned bounding box minimum.

Parameters
sizeNew size vector.
void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMinimum ( float  sizeX,
float  sizeY 
)
inlineprotected

Set desired size axis aligned bounding box minimum.

Parameters
sizeXNew desired minimum size X component.
sizeYNew desired minimum size Y component.
Vector2 kanzi::Node2D::getDesiredSizeAxisAlignedBoundingBoxMaximum ( ) const
inlineprotected

Get desired size axis aligned bounding box maximum.

Returns
Desired size maximum.
void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMaximum ( Vector2  size)
inlineprotected

Set desired size axis aligned bounding box maximum.

Parameters
sizeNew size vector.
void kanzi::Node2D::setDesiredSizeAxisAlignedBoundingBoxMaximum ( float  sizeX,
float  sizeY 
)
inlineprotected

Set desired size maximum.

Parameters
sizeXNew desired maximum size X component.
sizeYNew desired maximum size Y component.
void kanzi::Node2D::calculateTransformedBoundingArea ( const Matrix3x3 transform,
Vector2  sizeIn 
)
protected

Calculate new transformed bounding area.

Parameters
transformMatrix to use for calculation.
sizeInInput size.
Matrix3x3 kanzi::Node2D::updateFinalTransform ( const Matrix3x3 worldTransform,
const Matrix3x3 parentTransform 
)
protected

Update final transformation.

Updates the transformation status based on node properties and calculations in measure and arrange phases.

Called from within updateRender() if necessary (if transform has changed).

Parameters
worldTransformTransformation in world space.
parentTransformParent's transformation in its composition space.
Returns
Transformation of this node in its composition space.
bool kanzi::Node2D::updateRender ( const Matrix3x3 worldTransform,
const Matrix3x3 parentTransform,
bool  transformChanged 
)
protected

Validate node for rendering.

This is the final part of layouting. (Re)Calculate transformation components, decide whether or not to render to an FBO, etc.

Transformations are only recalculated if parent transform or node transform has been changed.

Parameters
worldTransformTransformation in world space.
parentTransformTransformation in parent space.
transformChangedIndicates whether transform (local or parent) has changed and needs updating.
Returns
True if there are additional reasons (detected during transform) to propagate transformation process downward.
virtual void kanzi::Node2D::updateRenderOverride ( )
protectedvirtual

Node-specific updates done before render.

Reimplemented in kanzi::Viewport2D, kanzi::ProgressiveRenderingViewport2D, kanzi::TextBlock2D, and kanzi::Image2D.

optional<QuadDescription> kanzi::Node2D::calculateContentStretch ( Vector2  renderSize,
Vector2  contentSize 
)
protected

Calculate content stretch.

Parameters
renderSizeRendering area size.
contentSizeSize of content rendered to rendering area.
foregroundTilingForeground tiling.
backgroundTilingBackground tiling.
Returns
optional foreground quad, if it's relevant.
ClippingArea kanzi::Node2D::calculateClippingArea ( const Matrix3x3 parentSpaceTransform) const
protected

Calculate clipping parameters.

Returns
New clipping parameters.
unsigned int kanzi::Node2D::performClipping ( QuadDescription backgroundQuad,
optional< QuadDescription > &  foregroundQuad,
unsigned int  clippingResult 
)
protected

Perform rectangle clipping.

Parameters
backgroundQuadBackground quad, modified in-place.
foregroundQuadOptional foreground quad, modified in-place.
Returns
New clipping mask.
void kanzi::Node2D::extractChildren ( ) const
protected

Extract children of node, called from extraction implementations.

virtual void kanzi::Node2D::onExtract ( )
protectedvirtual

Node2D extract function.

Reimplemented in kanzi::Viewport2D.

virtual void kanzi::Node2D::restoreResources ( )
protectedvirtual

Node::restoreResources() implementation.

Reimplemented from kanzi::Node.

Reimplemented in kanzi::Viewport2D, and kanzi::ProgressiveRenderingViewport2D.

bool kanzi::Node2D::isCompletelyClipped ( ) const
inlineprotected

Tell if node is completely clipped (and needs not be rendered).

Returns
True if yes, false if no.
bool kanzi::Node2D::isCompletelyTransparent ( ) const
inlineprotected

Tell if node is completely transparent.

Returns
True if yes, false if no.
bool kanzi::Node2D::isEmptyActualSize ( ) const
inlineprotected

Tell if the size of the node is empty or invalid.

Node must have positive size, greater than zero on both axes to be considered having a non-empty size.

Having empty size prevents rendering of node itself but not of its children.

bool kanzi::Node2D::isForegroundHintOpaque ( ) const
inlineprotected

Tell if foreground hint is opaque.

Returns
True if yes, false if no.
bool kanzi::Node2D::isForegroundHintTranslucent ( ) const
inlineprotected

Tell if foreground hint is translucent.

Returns
True if yes, false if no.
bool kanzi::Node2D::isForegroundTranslucencyRequested ( ) const
inlineprotected

Tell if foreground translucency has been requested.

Returns
True if yes, false if no.
void kanzi::Node2D::setForegroundTranslucencyRequested ( bool  enabled)
inlineprotected

Turn foreground translucency request on or off.

This is a way to request 'extra' translucency in updateRenderOverride() implementations inherited classes.

Parameters
enabledTrue to turn on, false to turn off.
void kanzi::Node2D::setPartialArrangeTransform ( Matrix3x3  transform)
inlineprotected

Sets partial arrange transform.

If the transform has changed, invalidates final transformation.

Parameters
transformNew partial arrange transform.
void kanzi::Node2D::setRenderChildrenAllowed ( bool  enabled)
inlineprotected

Turn render children on or off.

Parameters
enabledTrue to turn on, false to turn off.
void kanzi::Node2D::setRenderSelfAllowed ( bool  enabled)
inlineprotected

Turn render self on or off.

Parameters
enabledTrue to turn on, false to turn off.
void kanzi::Node2D::setRenderType ( RenderType  renderType)
inlineprotected

Set render type.

Parameters
renderTypeRender type.
void kanzi::Node2D::updateContentTexture ( TextureSharedPtr  texture)
inlineprotected

Update content texture for the foreground brush.

void kanzi::Node2D::setSecondPassDesiredSize ( Vector2  size)
inlineprotected

Set second pass desired size.

TODO: ugly

Parameters
sizeNew size vector.

Friends And Related Function Documentation

friend class Screen
friend
friend class Viewport3D
friend
void doListBoxArrange ( Node2D node)
friend

Member Data Documentation

PropertyType<float> kanzi::Node2D::AspectRatioProperty
static

AspectRatio property.

The default value is 1.0f.

See also
setAspectRatio(), getAspectRatio()
PropertyType<bool> kanzi::Node2D::ForceCompositionProperty
static

ForceComposition property.

The default value is false.

See also
setForceComposition(), isForceComposition()
PropertyType<Node2D::ForegroundHint> kanzi::Node2D::ForegroundHintProperty
static

ForegroundHint property.

The default value is Node2D::ForegroundHintNone.

See also
setForegroundHint(), getForegroundHint()
PropertyType<bool> kanzi::Node2D::CacheChildrenProperty
static

CacheChildren property.

The default value is false.

See also
setCacheChildren(), isCacheChildren()
PropertyType<bool> kanzi::Node2D::CacheResultProperty
static

CacheResult property.

The default value is false.

See also
setCacheResult(), isCacheResult()
PropertyType<bool> kanzi::Node2D::CacheSelfProperty
static

CacheSelf property.

The default value is false.

See also
setCacheSelf(), isCacheSelf()
PropertyType<bool> kanzi::Node2D::OffscreenRenderingProperty
static

OffscreenRendering property.

The default value is false.

See also
setOffscreenRendering(), isOffscreenRendering()
PropertyType<bool> kanzi::Node2D::DisableRenderTargetClearProperty
static

DisableRenderTargetClear property.

The default value is false.

See also
setDisableRenderTargetClear(), isDisableRenderTargetClear()
PropertyType<Node2D::PixelFormat> kanzi::Node2D::PixelFormatProperty
static

PixelFormat property.

The default value is Node2D::PixelFormatRgb.

See also
setPixelFormat(), getPixelFormat()
PropertyType<bool> kanzi::Node2D::RenderSelfProperty
static

RenderSelf property.

The default value is true.

See also
setRenderSelf(), isRenderSelf()
PropertyType<ResourceSharedPtr> kanzi::Node2D::RenderTargetProperty
static

RenderTarget property.

The default value is ResourceSharedPtr().

See also
setRenderTarget(), getRenderTarget()
PropertyType<float> kanzi::Node2D::RenderTargetMinimumHeightProperty
static

RenderTargetMinimumHeight property.

The default value is 1.0f.

See also
setRenderTargetMinimumHeight(), getRenderTargetMinimumHeight()
PropertyType<float> kanzi::Node2D::RenderTargetMinimumWidthProperty
static

RenderTargetMinimumWidth property.

The default value is 1.0f.

See also
setRenderTargetMinimumWidth(), getRenderTargetMinimumWidth()
PropertyType<float> kanzi::Node2D::RenderTargetReallocationLimitProperty
static

RenderTargetReallocationLimit property.

The default value is 0.25f.

See also
setRenderTargetReallocationLimit(), getRenderTargetReallocationLimit()
PropertyType<SRTValue2D> kanzi::Node2D::LayoutTransformationProperty
static

LayoutTransformation property.

The default value is SRT(Vector2(1.0f, 1.0f), 0.0f, Vector2(0.0f, 0.0f)).

See also
setLayoutTransformation(), getLayoutTransformation()
PropertyType<SRTValue2D> kanzi::Node2D::RenderTransformationProperty
static

RenderTransformation property.

The default value is SRT(Vector2(1.0f, 1.0f), 0.0f, Vector2(0.0f, 0.0f)).

See also
setRenderTransformation(), getRenderTransformation()
PropertyType<SRTValue3D> kanzi::Node2D::PerspectiveTransformationProperty
static

PerspectiveTransformation property.

The default value is identity.

See also
setPerspectiveTransformation, getPerspectiveTransformaton
PropertyType<Vector2> kanzi::Node2D::RenderTransformationOriginProperty
static

RenderTransformationOrigin property.

The default value is Vector2(0.0f, 0.0f).

See also
setRenderTransformationOrigin(), getRenderTransformationOrigin()
PropertyType<bool> kanzi::Node2D::SnapToPixelProperty
static

SnapToPixel property.

The default value is false.

See also
setSnapToPixel(), isSnapToPixel()
PropertyType<ResourceSharedPtr> kanzi::Node2D::BackgroundBrushProperty
static

BackgroundBrush property.

The default value is ResourceSharedPtr().

See also
setBackgroundBrush(), getBackgroundBrush()
PropertyType<ResourceSharedPtr> kanzi::Node2D::CompositionBrushProperty
static
PropertyType<ResourceSharedPtr> kanzi::Node2D::ForegroundBrushProperty
static

ForegroundBrush property.

The default value is ResourceSharedPtr().

See also
setForegroundBrush(), getForegroundBrush()
unique_ptr<NodeVisual2D> kanzi::Node2D::m_visual
protected

Visual information.

unique_ptr<NodeCompositor2D> kanzi::Node2D::m_compositor
protected

Composition and caching information.

QuadDescription kanzi::Node2D::m_backgroundQuadDescription
protected

Background clipping quad / composition quad description.

ClippingArea kanzi::Node2D::m_clipping
protected

Clipping parameters.

CompositionRequirements kanzi::Node2D::m_compositionRequirements
protected

Composition requirements for this 2D node.


The documentation for this class was generated from the following file: